23 using namespace basis;
36 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
43 virtual int execute();
46 int test_address::execute()
51 bool all_zero =
false;
54 if (!internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
56 "failed to say address was valid");
58 deadly_error(class_name(),
"1st address",
"said address was all zeros");
59 if ( (ip_form[0] != 12) || (ip_form[1] != 5) || (ip_form[2] != 55)
60 || (ip_form[3] != 37) )
61 deadly_error(class_name(),
"1st address",
"address had incorrect contents");
63 to_test =
"12.5.55.372";
64 if (internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
65 deadly_error(class_name(),
"2nd address",
"failed to say address was invalid");
67 to_test =
"12.5.55.37.3";
68 if (internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
69 deadly_error(class_name(),
"3rd address",
"failed to say address was invalid");
72 if (internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
73 deadly_error(class_name(),
"4th address",
"failed to say address was invalid");
76 if (!internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
77 deadly_error(class_name(),
"5th address",
"failed to say address was valid");
79 deadly_error(class_name(),
"5th address",
"said address was not all zeros");
80 if ( (ip_form[0] != 0) || (ip_form[1] != 0) || (ip_form[2] != 0)
81 || (ip_form[3] != 0) )
82 deadly_error(class_name(),
"5th address",
"address had incorrect contents");
85 if (!internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
86 deadly_error(class_name(),
"6th address",
"failed to say address was valid");
88 deadly_error(class_name(),
"6th address",
"said address was all zeros");
89 if ( (ip_form[0] != 0) || (ip_form[1] != 0) || (ip_form[2] != 0)
90 || (ip_form[3] != 1) )
91 deadly_error(class_name(),
"6th address",
"address had incorrect contents");
94 if (internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
95 deadly_error(class_name(),
"7th address",
"failed to say address was invalid");
98 if (internet_address::is_valid_internet_address(to_test, ip_form, all_zero))
99 deadly_error(class_name(),
"7th address",
"failed to say address was invalid");
101 to_test =
"this may have. an ip address in it somewhere... 92.21. 23.123. 1235.6.3 9 oops hey where is it. 23.51.2 2.4 1.2.343 09023.2.3. marbles 23.15.123.5 manus kobble 23.1.5.2 sturp nort ation";
103 if (!internet_address::has_ip_address(to_test, found))
104 deadly_error(class_name(),
"8th address",
"failed to find ip address");
105 ASSERT_EQUAL(found,
astring(
"23.15.123.5"),
"8th address: ip address found should be correct");
107 to_test =
"furples 92.23.1 9123.5.3 12398. 23 11 1 1 0202 2.4.1.5";
108 if (!internet_address::has_ip_address(to_test, found))
109 deadly_error(class_name(),
"9th address",
"failed to find ip address");
110 if (found !=
astring(
"2.4.1.5"))
111 deadly_error(class_name(),
"9th address",
astring(
"ip address found was wrong: ") + found +
", should have been 2.4.1.5");
113 to_test =
"12.5.55.2\"";
114 if (!internet_address::has_ip_address(to_test, found))
115 deadly_error(class_name(),
"10th address",
"failed to find ip address");
116 if (found !=
astring(
"12.5.55.2"))
117 deadly_error(class_name(),
"10th address",
astring(
"ip address found was wrong: ") + found +
", should have been 12.5.55.2");
119 to_test =
"12.5.55.2";
120 if (!internet_address::has_ip_address(to_test, found))
121 deadly_error(class_name(),
"11th address",
"failed to find ip address");
122 if (found !=
astring(
"12.5.55.2"))
123 deadly_error(class_name(),
"11th address",
astring(
"ip address found was wrong: ") + found +
", should have been 12.5.55.2");
125 return final_report();
The application_shell is a base object for console programs.
Provides a dynamically resizable ASCII character string.
A very common template for a dynamic array of bytes.
#define deadly_error(c, f, i)
#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.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
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 ASSERT_EQUAL(a, b, test_name)