42 #include "EST_Token.h"
44 static void binary_read_test();
51 for (tokens=0; !ts.
eof(); tokens++)
52 cout << ts.
get().string() << endl;
53 cout <<
"Total: " << tokens << endl << endl;;
57 int main(
int argc,
char **argv)
68 s =
"This is a test.";
69 cout <<
"Test 1: " << quote_string(s) << endl;
74 s =
"This (is) a test.";
75 cout <<
"Test 2: " << quote_string(s) << endl;
80 s =
"This (is) a test.";
81 cout <<
"Test 3: " << quote_string(s) << endl;
88 s =
"This (is) a test.";
89 cout <<
"Test 4: " << quote_string(s) << endl;
96 s =
"This \"is a\" te\\\"st.";
97 cout <<
"Test 5: " << quote_string(s) << endl;
104 s =
"This \"is a\" te\\\"st.";
105 cout <<
"Test 6: " << quote_string(s) << endl;
113 cout <<
"Test 7: " << quote_string(s) << endl;
132 sprintf(buff,
"a buffer BINARY ");
135 memmove(buff+16,a,
sizeof(
int)*2);
136 sprintf(buff+16+(
sizeof(
int)*2),
" and tokens");
138 if ((fd=fopen(filename,
"w")) == NULL)
140 cerr <<
"Token_regression: failed to open " << filename << endl;
144 numbytes = fwrite(buff,1,16+(
sizeof(
int)*2)+11,fd);
151 static void binary_read_test()
163 tokbinbuf = make_tokbins(
"tmp/tokbin.dat");
167 cout <<
"Reading tokens and binary from string\n";
171 cout << ts.
get() << endl;
172 cout << ts.
get() << endl;
173 if (ts.
get() !=
"BINARY")
175 cout <<
"failed to read binary data, missing BINARY token." << endl;
178 ts.
fread(b,
sizeof(
int),2);
179 cout << b[0] << endl;
180 cout << b[1] << endl;
181 cout << ts.
get() << endl;
182 cout << ts.
get() << endl;
185 cout <<
"Reading tokens and binary from file\n";
187 ts.
open(
"tmp/tokbin.dat");
189 cout << ts.
get() << endl;
190 cout << ts.
get() << endl;
191 if (ts.
get() !=
"BINARY")
193 cout <<
"failed to read binary data, missing BINARY token." << endl;
196 ts.
fread(b,
sizeof(
int),2);
197 cout << b[0] << endl;
198 cout << b[1] << endl;
199 cout << ts.
get() << endl;
200 cout << ts.
get() << endl;