Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / utility / tst_streambuf.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 // $XConsortium: tst_streambuf.C /main/4 1996/08/21 15:55:40 drk $
24
25 #include <iostream>
26 using namespace std;
27
28 #include "utility/debug.h"
29 #include "utility/c_charbuf.h"
30
31
32 streambuf_test1()
33 {
34    MESSAGE(cerr, "TEST 1");
35    char buf[5];
36    charbuf sb(buf, 5);
37
38    sb.put('a');
39    sb.put('b');
40    sb.put('c');
41
42    MESSAGE(cerr, "examine char a:");
43    debug(cerr, (char)sb.examine());
44
45    MESSAGE(cerr, "get char a:");
46    int c = sb.get();
47    debug(cerr, (char)c);
48
49    sb.put('d');
50    sb.put('e');
51
52    sb.putback(c);
53    MESSAGE(cerr, "putback char a:");
54    debug(cerr, (char)c);
55
56    MESSAGE(cerr, "get char a - e:");
57    debug(cerr, (char)sb.get());
58    debug(cerr, (char)sb.get());
59    debug(cerr, (char)sb.get());
60    debug(cerr, (char)sb.get());
61    debug(cerr, (char)sb.get());
62 }
63
64 streambuf_test2()
65 {
66    MESSAGE(cerr, "TEST 2");
67    char buf[5];
68    charbuf sb(buf, 5);
69
70    sb.put(0);
71    sb.put(1);
72
73    MESSAGE(cerr, "get 0:");
74    debug(cerr, sb.get());
75    MESSAGE(cerr, "get 1:");
76    debug(cerr, sb.get());
77    MESSAGE(cerr, "get -1:");
78    debug(cerr, sb.get());
79
80    sb.putback(2);
81    MESSAGE(cerr, "get 2:");
82    debug(cerr, sb.get());
83 }
84
85 streambuf_test3()
86 {
87    MESSAGE(cerr, "TEST 3");
88    char buf[5];
89    charbuf sb(buf, 5);
90
91    MESSAGE(cerr, "return 0:");
92    debug(cerr, sb.put(0));
93    MESSAGE(cerr, "return 0:");
94    debug(cerr, sb.put(1));
95    MESSAGE(cerr, "return 0:");
96    debug(cerr, sb.put(2));
97    MESSAGE(cerr, "return 0:");
98    debug(cerr, sb.put(3));
99    MESSAGE(cerr, "return 0:");
100    debug(cerr, sb.put(4));
101    MESSAGE(cerr, "return -1:");
102    debug(cerr, sb.put(5));
103    MESSAGE(cerr, "return -1:");
104    debug(cerr, sb.put(6));
105 }
106
107 streambuf_test4()
108 {
109    MESSAGE(cerr, "TEST 4");
110    char buf[5];
111    charbuf sb(buf, 5);
112
113    debug(cerr, sb.putback(0));
114    debug(cerr, sb.putback(1));
115    debug(cerr, sb.putback(2));
116    debug(cerr, sb.putback(3));
117    debug(cerr, sb.putback(4));
118
119    MESSAGE(cerr, "get 4:");
120    debug(cerr, sb.get());
121    MESSAGE(cerr, "get 3:");
122    debug(cerr, sb.get());
123    MESSAGE(cerr, "get 2:");
124    debug(cerr, sb.get());
125    MESSAGE(cerr, "get 1:");
126    debug(cerr, sb.get());
127    MESSAGE(cerr, "get 0:");
128    debug(cerr, sb.get());
129 }
130
131 main()
132 {
133    streambuf_test1();
134    streambuf_test2();
135    streambuf_test3();
136    streambuf_test4();
137 }