25 using namespace basis;
34 #define LOG(to_print) EMERGENCY_LOG(program_wide_logger::get(), astring(to_print))
44 int test_byte_format::execute()
50 source += 0x23; source += 0x5f; source += 0xa8; source += 0x2d;
51 source += 0xe2; source += 0x61; source += 0x90; source += 0x2d;
52 source += 0xf2; source += 0x38;
54 byte_formatter::bytes_to_shifted_string(source, shifty);
58 byte_formatter::shifted_string_to_bytes(shifty, source_copy);
59 ASSERT_EQUAL(source_copy, source,
"A: shifting corrupted the bytes.");
64 for (
int run = 0; run < 100; run++) {
67 for (
int i = 0; i < size; i++) {
71 byte_formatter::bytes_to_shifted_string(source, shifty);
75 byte_formatter::shifted_string_to_bytes(shifty, source_copy);
76 ASSERT_EQUAL(source_copy, source,
"B: shifting corrupted the bytes.");
81 astring burf(
"alia bodalia petunia");
82 astring dump(byte_formatter::text_dump((
abyte *)burf.s(), burf.length() + 1));
84 LOG(
"dumped form is:");
89 abyte fodder[] = { 0x83, 0x0d, 0x93, 0x21, 0x82, 0xfe, 0xef, 0xdc, 0xb9,
90 0xa9, 0x21, 0x54, 0x83, 0x38, 0x65, 0x59, 0x99, 0xff, 0x00, 0xa0,
94 byte_formatter::bytes_to_string(fred, as_text1,
true);
97 byte_formatter::bytes_to_string(fred, as_text2,
false);
100 byte_formatter::string_to_bytes(as_text1, convert1);
102 byte_formatter::string_to_bytes(as_text2, convert2);
103 ASSERT_EQUAL(fred, convert1,
"first abyte conversion: failed due to inequality");
104 ASSERT_TRUE(fred == convert2,
"second abyte conversion: failed due to inequality");
106 astring as_text3(
"muggulo x83d x93, x21, x82, xfe, xef, xdc, xb9, "
107 "xa9, x21, x54, x83, x38, x65, x59, x99, xff, x00a0, x293");
109 byte_formatter::string_to_bytes(as_text3, harder_convert1);
111 byte_formatter::bytes_to_string(harder_convert1, back3);
114 astring as_text4(
"muggulo x83d x93, x21, x82, xfe, xef, xdc, xb9, "
115 "xa9, x21, x54, x83, x38, x65, x59, x99, xff, x00a0, x293gikkor");
117 byte_formatter::string_to_bytes(as_text4, harder_convert2);
119 byte_formatter::bytes_to_string(harder_convert2, back4);
121 ASSERT_EQUAL(fred, harder_convert1,
"third abyte conversion: failed due to inequality");
122 ASSERT_EQUAL(fred, harder_convert2,
"fourth abyte conversion: failed due to inequality");
125 0x04, 0x00, 0x06, 0x00, 0x0a, 0x02, 0x03, 0x00, 0x06, 0x00, 0x48, 0x01, 0x1c, 0x00, 0x2c, 0x00, 0x04, 0x00, 0x09, 0x00, 0x17, 0x00, 0xff, 0xff, 0x00, 0x00,
126 0x00, 0x00, 0x09, 0x00 };
128 astring as_text5(
"040006000a020300060048011c002c00040009001700ffff000000000900");
130 byte_formatter::string_to_bytes(as_text5, harder_convert3);
132 byte_formatter::bytes_to_string(harder_convert3, back5);
134 ASSERT_EQUAL(fred, harder_convert3,
"fifth abyte conversion: failed due to inequality");
136 #ifndef EMBEDDED_BUILD
139 byte_formatter::text_dump(fred_dump, fred, 0x993834);
143 byte_formatter::parse_dump(fred_dump, fred_like);
144 ASSERT_EQUAL(fred, fred_like,
"parse_dump test: failed due to inequality");
150 LOG(
"0x3c5f in intel:");
151 LOG(byte_formatter::text_dump((
abyte *)&test1, 2));
153 LOG(
"0x9eaad0cb in intel:");
154 LOG(byte_formatter::text_dump((
abyte *)&test2, 4));
159 LOG(
"0x3c5f in package:");
160 LOG(byte_formatter::text_dump(testa));
163 LOG(
"0x9eaad0cb in package:");
164 LOG(byte_formatter::text_dump(testb));
167 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 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.
unsigned char abyte
A fairly important unit which is seldom defined...
unsigned int un_int
Abbreviated name for unsigned integers.
unsigned short un_short
Abbreviated name for unsigned short integers.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
void attach(byte_array &packed_form, const byte_array &to_attach)
Packs a byte_array "to_attach" into "packed_form".
Useful support functions for unit testing, especially within hoople.
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)