30 using namespace basis;
40 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
49 test_section_manager() {}
51 virtual int execute();
56 int test_section_manager::execute()
61 environment::set(
"ALLUSERSPROFILE", environment::get(
"TEMPORARIES_PILE"));
65 ini_configurator ini(
"t_section_manager_1.ini", ini_configurator::AUTO_STORE);
69 if (mangler.get_section_names(names)) {
70 for (
int i = 0; i < names.
length(); i++) mangler.zap_section(names[i]);
71 ini.delete_section(
"TOC");
76 contents1.
add(
"oink",
"bozoot");
77 contents1.
add(
"gink",
"rinkum");
78 contents1.
add(
"sorty",
"figulat");
79 contents1.
add(
"crinkish",
"wazir");
80 ASSERT_TRUE(mangler.add_section(
"burny", contents1),
81 TEST +
": couldn't add the first section!");
84 TEST +
": couldn't retrieve the first section!");
85 #ifdef DEBUG_SECTION_MANAGER
86 printf(
"first section has:\n%s\n", temp_1.
text_form().
s());
87 printf(
"we want:\n%s\n", contents1.
text_form().
s());
89 ASSERT_EQUAL(temp_1, contents1,
TEST +
": first section's contents are incorrect!");
90 contents1.
add(
"glurp",
"locutusburger");
92 TEST +
": incorrectly allowing re-add of first section!");
93 ASSERT_TRUE(mangler.replace_section(
"burny", contents1),
94 TEST +
": failing to replace first section!");
97 TEST +
": couldn't retrieve the first section (2)!");
98 ASSERT_EQUAL(temp_1, contents1,
TEST +
": first section's contents are incorrect (2)!");
101 contents2.
add(
"tsingha",
"tsinglo");
102 contents2.
add(
"chunk",
"midgets");
103 contents2.
add(
"burn",
"barns in texas");
104 contents2.
add(
"chump",
"will not be elected");
105 contents2.
add(
"geezerplant",
"water weekly");
106 ASSERT_TRUE(mangler.add_section(
"itchy", contents2),
107 TEST +
": couldn't add the second section!");
110 TEST +
": couldn't retrieve the second section!");
111 ASSERT_EQUAL(temp_2, contents2,
TEST +
": second section's contents are incorrect!");
114 TEST +
": couldn't retrieve the first section (3)!");
115 ASSERT_EQUAL(temp_1, contents1,
TEST +
": first section's contents are incorrect (3)!");
123 return final_report();
The application_shell is a base object for console programs.
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
Supports a configurator-based interface on text initialization files.
Tracks a collection of related configurations in a configurator.
An array of strings with some additional helpful methods.
Provides a symbol_table that holds strings as the content.
basis::astring text_form() const
prints the contents of the table into the returned string.
basis::outcome add(const basis::astring &name, const contents &storage)
Enters a symbol name into the table along with some contents.
#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_section_manager,)
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)
#define ASSERT_FALSE(a, test_name)