\hypertarget{adt_2gstack__test_8c-example}{
\section{adt/gstack\_\-test.c}
}


\begin{DocInclude}\begin{verbatim}1 /* $Id: gstack_test.c 710 2006-07-27 19:02:06Z bruce $ */
2 #include <stdlib.h>
3 #include <string.h>
4 
5 #include "gstack.h"
6 
7 #ifdef SELFTEST_MAIN
8 #include "selftest.c"
9 
10 GSTACK_DECL(test,int);
11 GSTACK_DEFN(test,int,0,0);
12 static struct gstack stack;
13 
14 MAIN
15 {
16   int i;
17   int* p;
18   for (i = 0; i < 4; ++i)
19     debugfn(test_push(&stack, &i));
20   while ((p = test_top(&stack)) != 0) {
21     obuf_puti(&outbuf, *p); NL();
22     test_pop(&stack);
23   }
24 }
25 
26 #endif
27 #ifdef SELFTEST_EXP
28 result=1
29 result=1
30 result=1
31 result=1
32 3
33 2
34 1
35 0
36 #endif
\end{verbatim}
\end{DocInclude}
 