31 using namespace basis;
39 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
60 virtual int execute();
63 int test_ini_parser::execute()
75 if (!par.get_section("twerf", twerf))
76 deadly_error(class_name(), "get_section 1", "twerf section was not found");
78 if (!twerf.find("noodles"))
79 deadly_error(class_name(), "get_section 1", "item
#1 was not found");
80 if (*twerf.find("noodles") != astring("fungus"))
81 deadly_error(class_name(), "get_section 1", "item #1 found is incorrect");
82 if (!twerf.find("dora"))
83 deadly_error(class_name(), "get_section 1", "item #2 was not found");
84 if (*twerf.find("dora") != astring("34"))
85 deadly_error(class_name(), "get_section 1", "item #2 found is incorrect");
88 if (!par.get_section("bork", bork))
89 deadly_error(class_name(), "get_section 2", "bork section was not found");
90 if (!bork.find("norple"))
91 deadly_error(class_name(), "get_section 2", "item #1 was not found");
92 if (*bork.find("norple") != astring("1"))
93 deadly_error(class_name(), "get_section 2", "item #1 found is incorrect");
94 if (!bork.find("train"))
95 deadly_error(class_name(), "get_section 2", "item #2 was not found");
96 if (*bork.find("train") != astring("12.5"))
97 deadly_error(class_name(), "get_section 2", "item #2 found is incorrect");
98 if (!bork.find("singhy"))
99 deadly_error(class_name(), "get_section 2", "item #3 was not found");
100 if (*bork.find("singhy") != astring("9"))
101 deadly_error(class_name(), "get_section 2", "item #3 found is incorrect");
104 par.restate(new_ini);
106 program_wide_logger::get().eol(parser_bits::CRLF_AT_END);
109 //hmmm: this could be a useful additional feature if it weren't a hard-coded filename;
110 // make this test take command line parameters which are interpreted as files to process here.
111 // loop over all of them and do the test.
112 #ifdef RUN_READ_FILE_TEST
113 byte_filer input("c:/home/fungal.lld", "rb");
114 int len = input.length();
115 LOG(a_sprintf("fungal len is %d", len));
117 input.read(jojo, len);
118 //LOG("whole file is:");
121 ini_parser klug(jojo);
127 critical_events::alert_message(astring(class_name()) + ": works for those functions tested.");
132 HOOPLE_MAIN(test_ini_parser, )
The application_shell is a base object for console programs.
Provides a dynamically resizable ASCII character string.
Parses strings in the fairly well-known INI file format.
A class that provides logging facilities vertically to all of hoople.
Provides a symbol_table that holds strings as the content.
Warehouses some functions that are often useful during text parsing.
#define deadly_error(c, f, i)
#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.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.