Merge branch 'release-2.140.101'
[feisty_meow.git] / nucleus / library / tests_nodes / test_node.cpp
1 /*****************************************************************************\
2 *                                                                             *
3 *  Name   : t_node                                                            *
4 *  Author : Chris Koeritz                                                     *
5 *                                                                             *
6 *  Purpose:                                                                   *
7 *                                                                             *
8 *    Tests out the node base class.                                           *
9 *                                                                             *
10 *******************************************************************************
11 * Copyright (c) 1989-$now By Author.  This program is free software; you can  *
12 * redistribute it and/or modify it under the terms of the GNU General Public  *
13 * License as published by the Free Software Foundation; either version 2 of   *
14 * the License or (at your option) any later version.  This is online at:      *
15 *     http://www.fsf.org/copyleft/gpl.html                                    *
16 * Please send any updates to: fred@gruntose.com                               *
17 \*****************************************************************************/
18
19 //hmmm: make this a more aggressive and realistic test.  try implementing
20 //      some list algorithms or graph algorithms to push node around.
21
22 #include <application/hoople_main.h>
23 #include <basis/astring.h>
24 #include <basis/byte_array.h>
25 #include <basis/functions.h>
26 #include <basis/guards.h>
27 #include <loggers/console_logger.h>
28 #include <nodes/node.h>
29 #include <structures/static_memory_gremlin.h>
30 #include <unit_test/unit_base.h>
31
32 using namespace application;
33 using namespace basis;
34 using namespace filesystem;
35 using namespace loggers;
36 using namespace mathematics;
37 using namespace nodes;
38 using namespace structures;
39 using namespace textual;
40 using namespace timely;
41 using namespace unit_test;
42
43 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
44
45 class test_node : public virtual unit_base, public virtual application_shell
46 {
47 public:
48   test_node() {}
49   DEFINE_CLASS_NAME("test_node");
50   virtual int execute();
51 };
52
53 void bogon(byte_array *fred)
54 {
55   if (fred) LOG("eep")
56   else LOG("eek");
57 }
58
59 int test_node::execute()
60 {
61   FUNCDEF("execute");
62
63   byte_array blank;
64   basket<byte_array> fred(2, blank);
65   basket<byte_array> george(2, blank);
66   basket<byte_array> f_end1(0);
67   basket<byte_array> f_end2(0);
68   basket<byte_array> g_end1(0);
69   basket<byte_array> g_end2(0);
70
71   node root;
72
73   // add some links to the linkless root.
74   root.insert_link(0, &fred);
75   root.insert_link(1, &george);
76
77   // set the pre-existing links to our end points.
78   fred.set_link(0, &f_end1);
79   fred.set_link(1, &f_end2);
80   george.set_link(0, &g_end1);
81   george.set_link(1, &g_end2);
82
83   return final_report();
84 }
85
86 HOOPLE_MAIN(test_node, );
87