feisty meow concerns codebase  2.140
test_node.cpp
Go to the documentation of this file.
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 
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>
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 //do some testing on those results!!!
84 
85  return final_report();
86 }
87 
88 HOOPLE_MAIN(test_node, );
89 
The application_shell is a base object for console programs.
A very common template for a dynamic array of bytes.
Definition: byte_array.h:36
the basket class holds an object and supports connecting them as nodes.
Definition: node.h:115
An object representing the interstitial cell in most linked data structures.
Definition: node.h:41
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
Definition: enhance_cpp.h:45
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Definition: enhance_cpp.h:57
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.
Definition: array.h:30
A platform independent way to obtain the timestamp of a file.
Definition: byte_filer.cpp:37
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
Definition: averager.h:21
A dynamic container class that holds any kind of object via pointers.
Definition: amorph.h:55
#include <time.h>
Definition: earth_time.cpp:37
Useful support functions for unit testing, especially within hoople.
Definition: unit_base.cpp:35
void bogon(byte_array *fred)
Definition: test_node.cpp:53
HOOPLE_MAIN(test_node,)
#define LOG(to_print)
Definition: test_node.cpp:43