27 using namespace basis;
37 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger::get(), astring(to_print))
47 virtual int execute();
52 int test_tokenizer::execute()
60 57 chevy heap=\"16 anagrams of misty immediately\"\n\
62 shouldus havus assignmentum=\n\
63 above better be parsed = 1\n\
64 ;and this comment too yo\n\
69 LOG(
astring(
"file before parsing:") + testing);
77 LOG(
"and in tabular form:");
78 LOG(jed.table().text_form());
86 ASSERT_TRUE(jed.exists(
"[frederick]"),
TEST +
"jed section header was omitted!");
88 TEST +
"jed section header had unexpected contents!");
90 TEST +
"jed's ted is missing or invalid!");
91 ASSERT_FALSE(jed.find(
"shouldus havus assignmentum").t(),
92 TEST +
"jed's shouldus had contents but shouldn't!");
93 astring value = *jed.table().
find(
"shouldus havus assignmentum");
95 ASSERT_TRUE(gorp.exists(
"[frederick]"),
TEST +
"gorp section header was omitted!");
97 TEST +
"gorp section header had unexpected contents!");
99 TEST +
"gorp's ted is missing or invalid!");
100 ASSERT_FALSE(gorp.find(
"shouldus havus assignmentum").t(),
101 TEST +
"gorp's shouldus had contents but shouldn't!");
102 value = *gorp.table().
find(
"shouldus havus assignmentum");
106 astring test_set_2 =
"Name=SRV, Parent=, Persist=Y, Entry=Y, Required=Y, Desc=Server, Tbl=Server";
110 LOG(
astring(
"file before parsing:") + testing);
116 LOG(
"and in tabular form:");
117 LOG(jed.table().text_form());
119 ASSERT_FALSE(jed.find(
"Parent").t(),
TEST +
"Parent had contents but shouldn't!");
129 tantalus rex=gumby \"don#t\n\n'play'\nthat\" homey '\n\ndog\n\n yo \"\ncreen\" arf'\n\
130 57 chevy heap=\"16 anagrams of misty immediately\"\n\
132 shouldus havus assignmentum=\n\
133 above better be parsed = 1\n\
134 ;and this comment too yo\n\
139 LOG(
astring(
"file before parsing:") + testing);
147 LOG(
"and in tabular form:");
148 LOG(jed.table().text_form());
149 ASSERT_TRUE(jed.exists(
"[frederick]"),
TEST +
"jed section header was omitted!");
151 TEST +
"jed section header had unexpected contents!");
153 ASSERT_FALSE(jed.find(
"shouldus havus assignmentum").t(),
154 TEST +
"jed shouldus had contents but shouldn't!");
155 astring value = *jed.table().
find(
"shouldus havus assignmentum");
157 ASSERT_TRUE(gorp.exists(
"[frederick]"),
TEST +
"gorp section header was omitted!");
159 TEST +
"gorp section header had unexpected contents!");
161 ASSERT_FALSE(gorp.find(
"shouldus havus assignmentum").t(),
162 TEST +
"gorp shouldus had contents but shouldn't!");
163 value = *gorp.table().
find(
"shouldus havus assignmentum");
165 ASSERT_TRUE(gorp.exists(
"tantalus rex"),
TEST +
"gorp tantalus rex is missing!");
167 astring(
"gumby \"don#t\n\n'play'\nthat\" homey '\n\ndog\n\n yo "
169 TEST +
"gorp tantalus rex has incorrect contents!");
174 treadmill=\"this ain't the place\nwhere'n we been done\nseein' no quotes\"\n\
175 borfulate='similarly \"we\" do not like\nthe \" quote \" type thing here'\n\
180 LOG(
astring(
"file before parsing:\n") + testing);
188 LOG(
"and in tabular form:");
189 LOG(jed.table().text_form());
190 ASSERT_TRUE(gorp.exists(
"[garfola]"),
TEST +
"section header was omitted!");
192 TEST +
"section header had unexpected contents!");
195 astring(
"\"this ain't the place\nwhere'n we been done\nseein' no quotes\""),
196 TEST +
"treadmill has incorrect contents!");
199 astring(
"'similarly \"we\" do not like\nthe \" quote \" type thing here'"),
200 TEST +
"borfulate has incorrect contents!");
204 x~35; y~92 ;#comment ; d ~83 ; e~ 54 ; ? new comment ;sud ~ xj23-8 ; nigh ~2";
208 LOG(
astring(
"file before parsing:\n") + testing);
210 jed.set_comment_chars(
"#?");
215 LOG(
"and in tabular form:");
216 LOG(jed.table().text_form());
219 gorp.set_comment_chars(
"#?");
221 LOG(
"gorp in tabular form:");
222 LOG(gorp.table().text_form());
224 ASSERT_TRUE(gorp.table() == jed.table(),
TEST +
"gorp text not same as jed!");
234 astring test_set_6 =
"\r\n\r\n\r\
235 # this is yet another test with comments.\r\n\
236 ; we want to be sure stuff works right.\r\n\
239 shagbot =once upon a time there was a man \r\n\
240 \t\t\tpunzola megamum =brandle the handle \r\n\
242 mensch = racer X\r\n\
247 LOG(
astring(
"file before parsing:\n===========\n") + testing +
"\n===========");
249 jed.set_comment_chars(
"#;");
253 LOG(
astring(
"file after parsing:\n===========\n") + out +
"\n===========");
254 LOG(
"and in tabular form:");
255 LOG(jed.table().text_form());
258 gorp.set_comment_chars(
"#;");
260 LOG(
"gorp in tabular form:");
261 LOG(gorp.table().text_form());
262 LOG(
a_sprintf(
"gorp has %d fields, jed has %d fields", gorp.symbols(), jed.symbols()));
263 ASSERT_TRUE(gorp.table() == jed.table(),
TEST +
"gorp text not same as jed!");
266 TEST +
"value for crumpet missing or invalid");
268 TEST +
"value for moomar missing or invalid");
270 TEST +
"value for shagbot missing or invalid");
272 TEST +
"value for trapzoot missing or invalid");
274 TEST +
"value for punzola missing or invalid");
276 TEST +
"value for mensch missing or invalid");
279 return final_report();
The application_shell is a base object for console programs.
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
virtual void text_form(base_string &state_fill) const
Provides a text view of all the important info owned by this object.
int find(char to_find, int position=0, bool reverse=false) const
Locates "to_find" in "this".
Manages a bank of textual definitions of variables.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
HOOPLE_MAIN(test_tokenizer,)
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)
#define ASSERT_FALSE(a, test_name)