42 using namespace basis;
46 using namespace nodes;
60 #define LOG(s) EMERGENCY_LOG(program_wide_logger::get(), s)
62 #define WHERE __WHERE__.s()
64 #define FUNKIT(str) basis::a_sprintf("%s: %s", func, basis::astring(str).s())
76 test_packable_tree() {}
77 ~test_packable_tree() {}
81 virtual int execute() {
83 return final_report();
100 virtual ~many_tree() {
WHACK(c_inf); }
102 file_info get_info()
const {
return *c_inf; }
105 return c_inf->packed_size();
109 c_inf->pack(packed_form);
113 if (!c_inf->unpack(packed_form))
return false;
134 void test_packable_tree::run_test()
144 many_tree gruntcake(farfle);
146 int pack_guess = gruntcake.packed_size();
147 gruntcake.pack(packed_form);
149 many_tree untbake_target(empty);
150 ASSERT_TRUE(untbake_target.unpack(packed_form),
FUNKIT(
"unpack operation failed"));
151 ASSERT_EQUAL(untbake_target.get_info(), gruntcake.get_info(),
152 FUNKIT(
"unpack had wrong contents"));
158 many_tree *spork =
new many_tree(farfle);
159 many_tree *limpet =
new many_tree(empty);
160 many_tree *congo =
new many_tree(snood);
161 many_tree *dworkin =
new many_tree(empty);
162 many_tree *greep =
new many_tree(farfle);
164 many_tree *flep =
new many_tree(snood);
165 many_tree *glug =
new many_tree(empty);
166 many_tree *aptitoot =
new many_tree(farfle);
168 many_tree *grog =
new many_tree(snood);
171 flep->attach(limpet);
173 aptitoot->attach(dworkin);
174 aptitoot->attach(greep);
178 grog->attach(aptitoot);
182 int size_guess = grog->recursive_packed_size();
183 grog->recursive_pack(packed);
185 tree_defacto factotum;
188 ASSERT_TRUE(
dynamic_cast<many_tree *
>(unpacked),
"recursive_unpack has wrong type");
189 many_tree *survivor =
dynamic_cast<many_tree *
>(unpacked);
The application_shell is a base object for console programs.
int length() const
Returns the current reported length of the allocated C array.
A very common template for a dynamic array of bytes.
Encapsulates some measures and calculations based on a file's contents.
Provides operations commonly needed on file names.
A tree object that can be packed into an array of bytes and unpacked again.
static packable_tree * recursive_unpack(basis::byte_array &packed_form, packable_tree_factory &creator)
unpacks a tree stored in "packed_form" and returns it.
#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.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
const int MINUTE_ms
Number of milliseconds in a minute.
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.
bool unpack(basis::byte_array &packed_form, set< contents > &to_unpack)
provides a way to unpack any set that stores packable objects.
void pack(basis::byte_array &packed_form, const set< contents > &to_pack)
provides a way to pack any set that stores packable objects.
int packed_size(const byte_array &packed_form)
Reports the size required to pack a byte array into a byte array.
Useful support functions for unit testing, especially within hoople.
const float TEST_RUNTIME_DEFAULT
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)