33 #ifdef DEBUG_INI_CONFIGURATOR_TEST
37 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
39 #define UNWANTED_DEFAULT_VALUE 9949494.3
43 using namespace basis;
52 #define WHERE __WHERE__.s()
57 #define static_class_name() "test_ini_configurator"
59 #define MACRO_AS_STRING(s) #s
65 ini_configurator ini(
"t_ini_configurator.ini", ini_configurator::AUTO_STORE);
69 LOG(
astring(
"exe directory is currently: ") + application_configuration::application_directory());
75 const char *TEST_NAME =
"first test: rectangle";
83 if (win_size != default_rectangle)
85 "rectangle not equal to default");
92 if (current_size != new_size)
94 "rectangle not equal to second size stored");
98 const char *TEST_NAME =
"second test: string";
99 astring junk(
"this is a junky string to be stored as bytes....");
102 byte_formatter::bytes_to_string(to_store, as_bytes);
103 ini.
store(
"test_of_byte_store",
"test1", as_bytes);
105 astring rettle = ini.
load(
"test_of_byte_store",
"test1", blort);
107 byte_formatter::string_to_bytes(rettle, found_byte);
111 "ini_configurator load failed: default was used");
112 else if (found_junk != junk)
114 "ini_configurator load failed: result differed from original");
118 const char *TEST_NAME =
"third test: frunkle";
119 frunkle def_frunkle(3.14159265358);
126 "ini_configurator load failed: default was used");
127 if (found_frunkle != def_frunkle)
129 "ini_configurator load failed: saved value differed");
133 const char *TEST_NAME =
"fourth test: frunkle";
134 frunkle def_frunkle(1487335673.1415926535834985987);
136 ini.
store(
"test",
"frunkle_test", def_text);
139 if (found_frunkle ==
frunkle(0.0))
141 "ini_configurator load failed: float conversion failed--got zero");
144 "ini_configurator load failed: wrong unwanted default was used");
145 if (found_frunkle != def_frunkle)
147 "ini_configurator load failed: saved value differed");
151 const char *TEST_NAME =
"fifth test: bytes";
153 astring junk(
"this is a junky string to be stored as bytes....");
156 byte_formatter::bytes_to_string(default_bytes, defbytes_string);
158 astring tmp = ini.
load(
"test_of_byte_store",
"test1", defbytes_string);
159 byte_formatter::string_to_bytes(tmp, found);
161 if (string_found == urp)
163 "ini_configurator load_bytes failed: default was used");
166 "ini_configurator load_bytes failed: array lengths differ");
167 if (string_found != junk)
169 "ini_configurator load_bytes failed: arrays differ");
173 const char *TEST_NAME =
"sixth test: blank string";
176 astring fund = ini.
load(
"test_of_blank_string",
"test1", blank);
179 "with blank default failed: didn't return blank");
181 astring non_blank(
"blinkblankblunk");
182 fund = ini.
load(
"test_of_blank_string",
"test1", non_blank);
183 if (fund != non_blank)
185 "with non-blank default failed: didn't return default");
186 fund = ini.
load(
"test_of_blank_string",
"test1", blank);
187 if (fund != non_blank)
189 "with blank default failed: returned wrong string");
const contents * observe() const
Returns a pointer to the underlying C array of data.
Provides a dynamically resizable ASCII character string.
int convert(int default_value) const
Converts the string into a corresponding integer.
int length() const
Returns the current length of the string.
virtual const char * observe() const
observes the underlying pointer to the zero-terminated string.
A very common template for a dynamic array of bytes.
bool store(const basis::astring §ion, const basis::astring &entry, const basis::astring &to_store)
a synonym for put.
basis::astring load(const basis::astring §ion, const basis::astring &entry, const basis::astring &default_value)
a synonym for get that implements the auto-store behavior.
Supports a configurator-based interface on text initialization files.
virtual bool delete_entry(const basis::astring §ion, const basis::astring &entry)
removes the entry specified by the "section" and "entry" name.
basis::astring name() const
observes the name of the file used for ini entries.
basis::astring text_form() const
Prints out the contents of the rectangle.
bool from_text(const basis::astring &text)
Returns true if the "text" is parsed into this rectangle.
Represents a rectangle as interpreted on display screens.
double value() const
observes the value held in this.
#define deadly_error(c, f, i)
#define formal(parameter)
This macro just eats what it's passed; it marks unused formal parameters.
#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.
The guards collection helps in testing preconditions and reporting errors.
unsigned char abyte
A fairly important unit which is seldom defined...
Contains all of our objects for geometry and avoids name clashes.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
#define UNWANTED_DEFAULT_VALUE
int main(int formal(argc), char *formal(argv)[])
const int test_iterations
#define static_class_name()
#define MACRO_AS_STRING(s)