25 using namespace basis;
35 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
37 #define DEBUG_SPAN_MANAGER
43 #define INIT_STUFF int_array stuffer;
46 #define STUFF(a, b) { \
47 ASSERT_FALSE(stuffer.length() / 2 + 1 > MAX_SPANS, "STUFF: too many for spans"); \
48 stuffer.concatenate(a); stuffer.concatenate(b); \
53 #define SEND(send_to) \
54 send_to.update(stuffer); stuffer.reset(0);
58 #define COMP(to_compare, i) { \
59 ASSERT_EQUAL(to_compare, rec_list[i], "comparison found incorrect"); \
60 if (to_compare != rec_list[i]) LOG(a_sprintf("failed at index %d", i)); \
66 test_span_manager() {}
68 virtual int execute();
71 int test_span_manager::execute()
94 #ifdef DEBUG_SPAN_MANAGER
95 LOG(
astring(astring::SPRINTF,
"received sequence so far is %d",
96 fred.received_sequence()));
97 LOG(
"making received list:");
101 fred.make_received_list(rec_list);
103 #ifdef DEBUG_SPAN_MANAGER
104 LOG(fred.print_received_list());
109 for (
int i = 0; i < rec_list.
length(); i += 2) {
111 case 0:
COMP(3, i);
COMP(6, i+1);
break;
112 case 2:
COMP(8, i);
COMP(8, i+1);
break;
113 case 4:
COMP(13, i);
COMP(17, i+1);
break;
114 case 6:
COMP(27, i);
COMP(31, i+1);
break;
115 case 8:
COMP(80, i);
COMP(83, i+1);
break;
116 case 10:
COMP(96, i);
COMP(123, i+1);
break;
117 case 12:
COMP(151, i);
COMP(430, i+1);
break;
121 ASSERT_EQUAL(fred.missing_sequence(), 0,
"missing: should not have wrong sequence");
128 ASSERT_EQUAL(fred.missing_sequence(), 18,
"missing 2: should not have wrong sequence");
129 #ifdef DEBUG_SPAN_MANAGER
130 LOG(
"here are the missing ones now:");
131 LOG(fred.print_missing_list());
133 fred.make_missing_list(rec_list);
136 for (
int j = 0; j < rec_list.
length(); j+=2) {
138 case 0:
COMP(18, j);
COMP(26, j+1);
break;
139 case 2:
COMP(32, j);
COMP(79, j+1);
break;
140 case 4:
COMP(84, j);
COMP(95, j+1);
break;
141 case 6:
COMP(124, j);
COMP(150, j+1);
break;
142 case 8:
COMP(431, j);
COMP(451, j+1);
break;
148 #ifdef DEBUG_SPAN_MANAGER
149 LOG(
"should be filled out now:");
150 LOG(fred.print_received_list());
152 ASSERT_EQUAL(fred.received_sequence(), 451,
"received sequence should be filled out");
154 return final_report();
The application_shell is a base object for console programs.
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
A simple object that wraps a templated array of ints.
Manages lists of numbers representing the completion of some activity.
#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.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
A logger that sends to the console screen using the standard output device.
Provides access to the operating system's socket methods.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
#define COMP(to_compare, i)
stuffer.number_of_spans = stuff_index / 2; \ old
HOOPLE_MAIN(test_span_manager,)
#define ASSERT_EQUAL(a, b, test_name)