* Please send any updates to: fred@gruntose.com *
\*****************************************************************************/
+#include <application/application_shell.h>
+#include <application/hoople_main.h>
#include <basis/byte_array.h>
-#include <mathematics/chaos.h>
#include <basis/guards.h>
#include <basis/astring.h>
-#include <octopus/entity_defs.h>
-#include <application/application_shell.h>
+#include <configuration/application_configuration.h>
#include <loggers/console_logger.h>
#include <loggers/file_logger.h>
-#include <structures/static_memory_gremlin.h>
+#include <loggers/program_wide_logger.h>
+#include <mathematics/chaos.h>
+#include <octopus/entity_defs.h>
#include <sockets/tcpip_stack.h>
+#include <structures/static_memory_gremlin.h>
#include <textual/string_manipulation.h>
+#include <unit_test/unit_base.h>
#ifdef __WIN32__
#include <process.h>
#include <unistd.h>
#endif
+using namespace application;
+using namespace basis;
+using namespace configuration;
+using namespace loggers;
+using namespace mathematics;
+using namespace octopi;
+using namespace sockets;
+using namespace textual;
+using namespace unit_test;
+
+#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
+
const int ITERATE_EACH_TEST = 1000;
// the number of times to repeat each test operation.
-class test_entity : public application_shell
+class test_entity : virtual public unit_base, virtual public application_shell
{
public:
- test_entity() : application_shell(class_name()) {}
+ test_entity() : application_shell() {}
+//class_name()
DEFINE_CLASS_NAME("test_entity");
virtual int execute();
};
int test_entity::execute()
{
+ FUNCDEF("execute");
chaos rando;
- SET_DEFAULT_COMBO_LOGGER;
+/// SET_DEFAULT_COMBO_LOGGER;
tcpip_stack stack;
octopus_entity blankie;
for (int i = 0; i < ITERATE_EACH_TEST; i++) {
// test the basic filling of the values in an entity.
octopus_entity blank_ent;
- int sequencer = rando.inclusive(1, MAXINT - 10);
- int add_in = rando.inclusive(0, MAXINT - 10);
+ int sequencer = rando.inclusive(1, MAXINT32 - 10);
+ int add_in = rando.inclusive(0, MAXINT32 - 10);
octopus_entity filled_ent(stack.hostname(), application_configuration::process_id(), sequencer,
add_in);
blank_ent = octopus_entity(stack.hostname(), application_configuration::process_id(), sequencer,
astring text2 = blank_ent.to_text();
if (text1 != text2)
deadly_error(class_name(), "to_text test", "strings are different");
-///log(text1);
+///LOG(text1);
octopus_entity georgio = octopus_entity::from_text(text2);
-///log(georgio.to_text());
+///LOG(georgio.to_text());
if (georgio != filled_ent)
deadly_error(class_name(), "from_text test",
"entity is different after from_text");
if (blank_ent != filled_ent)
deadly_error(class_name(), "reset from attribs test",
"failed to resolve to same id");
-// log(a_sprintf("%d: ", i + 1) + filled_ent.mangled_form());
+// LOG(a_sprintf("%d: ", i + 1) + filled_ent.mangled_form());
byte_array chunk1;
filled_ent.pack(chunk1);
// test of entity packing and size calculation.
octopus_entity ent(string_manipulation::make_random_name(1, 428),
- randomizer().inclusive(0, MAXINT/2),
- randomizer().inclusive(0, MAXINT/2),
- randomizer().inclusive(0, MAXINT/2));
- octopus_request_id bobo(ent, randomizer().inclusive(0, MAXINT/2));
+ randomizer().inclusive(0, MAXINT32/2),
+ randomizer().inclusive(0, MAXINT32/2),
+ randomizer().inclusive(0, MAXINT32/2));
+ octopus_request_id bobo(ent, randomizer().inclusive(0, MAXINT32/2));
int packed_estimate = bobo.packed_size();
byte_array packed_bobo;
bobo.pack(packed_bobo);
}
- log("octopus_entity:: works for those functions tested.");
+ LOG(astring(class_name()) + ":: works for those functions tested.");
return 0;
}
* Please send any updates to: fred@gruntose.com *
\*****************************************************************************/
+#include <application/application_shell.h>
+#include <application/hoople_main.h>
#include <basis/astring.h>
+#include <loggers/console_logger.h>
+#include <loggers/critical_events.h>
+#include <loggers/program_wide_logger.h>
#include <octopus/entity_defs.h>
#include <octopus/identity_infoton.h>
#include <octopus/infoton.h>
#include <octopus/octopus.h>
#include <octopus/tentacle.h>
-#include <application/application_shell.h>
-#include <loggers/console_logger.h>
#include <structures/static_memory_gremlin.h>
+#include <unit_test/unit_base.h>
+
+using namespace application;
+using namespace basis;
+//using namespace configuration;
+using namespace loggers;
+using namespace mathematics;
+using namespace octopi;
+//using namespace sockets;
+using namespace textual;
+using namespace unit_test;
+
+#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
//////////////
-class test_octopus_identity : public application_shell
+class test_octopus_identity : virtual public unit_base, virtual public application_shell
{
public:
- test_octopus_identity() : application_shell(class_name()) {}
+ test_octopus_identity() : application_shell() {}
+//class_name()
DEFINE_CLASS_NAME("test_octopus_identity");
virtual int execute();
};
int test_octopus_identity::execute()
{
+ FUNCDEF("execute")
octopus logos("local", 18 * MEGABYTE);
identity_infoton *ide = new identity_infoton;
deadly_error(class_name(), "evaluate test",
astring("the evaluation failed with an error ")
+ tentacle::outcome_name(ret));
-log("point a");
+LOG("point a");
octopus_request_id response_id; // based on bogus from before.
infoton *response = logos.acquire_result(junk_id._entity, response_id);
octopus_entity my_ide = new_id->_new_name;
-log(astring("new id is: ") + my_ide.text_form());
+LOG(astring("new id is: ") + my_ide.text_form());
if (my_ide.blank())
deadly_error(class_name(), "retrieving id",
astring("the new entity id is blank."));
- log("octopus:: identity works for those functions tested.");
+ LOG("octopus:: identity works for those functions tested.");
return 0;
}
* Please send any updates to: fred@gruntose.com *
\*****************************************************************************/
+#include <application/application_shell.h>
+#include <application/hoople_main.h>
#include <basis/astring.h>
#include <basis/mutex.h>
-#include <structures/static_memory_gremlin.h>
+#include <configuration/application_configuration.h>
+#include <loggers/console_logger.h>
+#include <loggers/critical_events.h>
+#include <loggers/program_wide_logger.h>
#include <octopus/entity_defs.h>
#include <octopus/infoton.h>
#include <octopus/octopus.h>
#include <octopus/tentacle.h>
-#include <application/application_shell.h>
-#include <loggers/console_logger.h>
#include <structures/static_memory_gremlin.h>
#include <sockets/internet_address.h>
+//#include <structures/static_memory_gremlin.h>
+#include <structures/string_array.h>
#include <tentacles/login_tentacle.h>
#include <tentacles/simple_entity_registry.h>
+#include <unit_test/unit_base.h>
+
+using namespace application;
+using namespace basis;
+using namespace configuration;
+using namespace loggers;
+using namespace mathematics;
+using namespace octopi;
+using namespace sockets;
+using namespace structures;
+using namespace textual;
+using namespace unit_test;
+
+#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
//////////////
simple_infoton() : infoton(simp_classifier()) {}
+ virtual void text_form(basis::base_string &state_fill) const {
+ state_fill.concatenate_string(astring("futzle=") + futzle);
+ }
+
virtual void pack(byte_array &packed_form) const {
futzle.pack(packed_form);
}
// a while, log out, do another one, let it time out, try to access
// something with dead id hoping to be rejected, etc.
-class test_octopus_security : public application_shell
+class test_octopus_security : virtual public unit_base, virtual public application_shell
{
public:
- test_octopus_security() : application_shell(class_name()) {}
+ test_octopus_security() : application_shell() {}
+//class_name()
DEFINE_CLASS_NAME("test_octopus_security");
virtual int execute();
};
int test_octopus_security::execute()
{
+ FUNCDEF("execute")
octopus logos("local", 18 * MEGABYTE);
simple_tentacle *tenty = new simple_tentacle;
logos.add_tentacle(tenty);
astring("the operation failed with an error ")
+ tentacle::outcome_name(ret));
- log("octopus:: security works for those functions tested.");
+ LOG(astring(class_name()) + ":: security works for those functions tested.");
WHACK(guardian);
* Please send any updates to: fred@gruntose.com *
\*****************************************************************************/
+#include <application/application_shell.h>
+#include <application/hoople_main.h>
#include <basis/astring.h>
-#include <structures/static_memory_gremlin.h>
+#include <loggers/console_logger.h>
+#include <loggers/file_logger.h>
+#include <loggers/program_wide_logger.h>
#include <octopus/entity_defs.h>
#include <octopus/infoton.h>
#include <octopus/octopus.h>
#include <octopus/tentacle_helper.h>
-#include <application/application_shell.h>
-#include <loggers/console_logger.h>
-#include <loggers/file_logger.h>
-#include <structures/static_memory_gremlin.h>
#include <sockets/internet_address.h>
+#include <structures/static_memory_gremlin.h>
+#include <structures/string_array.h>
+#include <unit_test/unit_base.h>
+
+using namespace application;
+using namespace basis;
+using namespace configuration;
+using namespace loggers;
+using namespace mathematics;
+using namespace octopi;
+using namespace sockets;
+using namespace structures;
+using namespace textual;
+using namespace unit_test;
+
+#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), astring(s))
//hmmm: provide equality ops to be able to check that same stuff
// came back out that went in.
-class test_unpacker : public application_shell
+class test_unpacker : virtual public unit_base, virtual public application_shell
{
public:
- test_unpacker() : application_shell(class_name()) {}
+ test_unpacker() : application_shell() {}
DEFINE_CLASS_NAME("test_unpacker");
virtual int execute();
void test_unpacking();
SAFE_STATIC_CONST(string_array, addr_classifier, (base_classifier()
+ string_array(1, addr_list)))
-class address_ton : public infoton, public network_address
+class address_ton : public infoton, public internet_address
{
public:
address_ton() : infoton(addr_classifier() + "leaf") {}
+ const char *class_name() const { return "address_ton"; }
+
virtual void pack(byte_array &packed_form) const {
- network_address::pack(packed_form);
+ internet_address::pack(packed_form);
+ }
+
+ virtual void text_form(basis::base_string &state_fill) const {
+ state_fill.concatenate_string(internet_address::text_form());
}
virtual bool unpack(byte_array &packed_form) {
- return network_address::unpack(packed_form);
+ return internet_address::unpack(packed_form);
}
virtual int packed_size() const {
float_ton() : infoton(math_classifier() + "float") {}
+ const char *class_name() const { return "float_ton"; }
+
virtual void pack(byte_array &packed_form) const {
structures::attach(packed_form, f1);
structures::attach(packed_form, d1);
}
+ virtual void text_form(basis::base_string &state_fill) const {
+ state_fill.concatenate_string(a_sprintf("f1=%f d1=%f", f1, d1));
+ }
+
virtual int packed_size() const {
return sizeof(double) + sizeof(float);
}
int_set_ton() : infoton(math_classifier() + "intset") {}
+ const char *class_name() const { return "int_set_ton"; }
+
+ virtual void text_form(basis::base_string &state_fill) const {
+ state_fill.concatenate_string(astring("( "));
+ for (int indy = 0; indy < nums.length(); indy++) {
+ state_fill.concatenate_string(a_sprintf("%d", nums[indy]));
+ if (indy < nums.length() - 1) {
+ state_fill.concatenate_string(astring(", "));
+ }
+ }
+ state_fill.concatenate_string(astring(" )"));
+ }
+
virtual void pack(byte_array &packed_form) const {
structures::attach(packed_form, nums.elements());
for (int i = 0; i < nums.elements(); i++)
reformed = NULL_POINTER;
if (classifier.length() < 2) return BAD_INPUT;
astring key = classifier[1];
- if (key == "float") {
+ if (key == astring("float")) {
float_ton *to_return = new float_ton;
if (!to_return->unpack(packed_form)) {
WHACK(to_return);
}
reformed = to_return;
return OKAY;
- } else if (key == "intset") {
+ } else if (key == astring("intset")) {
int_set_ton *to_return = new int_set_ton;
if (!to_return->unpack(packed_form)) {
WHACK(to_return);
real_class.zap(0, 0);
to_chow.set_classifier(real_class);
// route to octopus.
- return _unpackers.evaluate((infoton *)to_chow.clone(), item_id);
+ return _unpackers.evaluate(dynamic_cast<infoton *>(to_chow.clone()), item_id);
}
void expunge(const octopus_entity &formal(whackola)) {}
chunkmo += 0x37;
chunkmo += 0x65;
address_ton norf;
- (network_address &)norf = network_address(internet_address
+ (internet_address &)norf = internet_address(internet_address
(chunkmo, "urp", 23841));
chunkmo.reset();
infoton::fast_pack(chunkmo, norf);
if (!infoton::fast_unpack(chunkmo, clarfiator, pacula))
deadly_error(class_name(), "test fast_unpack", "chunkmo has errors");
infoton *scrung = NULL_POINTER;
-//log(astring("classif is ") + clarfiator.text_form());
+//LOG(astring("classif is ") + clarfiator.text_form());
outcome scrung_ret = unpacky.restore(clarfiator, pacula, scrung);
if (scrung_ret != tentacle::OKAY)
if (!rescrung)
deadly_error(class_name(), "test fast_unpack", "wrong dynamic type for scrung");
address_ton &prescrung = *rescrung;
- if ((network_address &)prescrung != (network_address &)norf)
+ if ((internet_address &)prescrung != (internet_address &)norf)
deadly_error(class_name(), "test fast_unpack", "wrong network address restored");
WHACK(scrung);
}
int test_unpacker::execute()
{
+ FUNCDEF("execute");
int iters = 0;
while (iters++ < MAXIMUM_TESTS) {
-//log(a_sprintf("iter #%d", iters));
+//LOG(a_sprintf("iter #%d", iters));
test_unpacking();
}
- log("unpacking octopus:: works for all functions tested.");
+ LOG(astring(class_name()) + ":: works for all functions tested.");
//time_control::sleep_ms(30000);
return 0;
}