19 #define DO_HEXDUMP(off,hex,ascii,width,gap,space) \
21 MemDump(off, hex, ascii, width, gap,space) \
22 .dump_to(str, buf, len)
24 #define TEST_HEXDUMP_EQUAL(width,gap,off,hex,ascii,space,expected) do { \
25 DO_HEXDUMP(off,hex,ascii,width,gap,space); \
26 TEST_EXPECT_EQUAL(str.get_data(), expected); \
29 #define TEST_HEXDUMP_EQUAL__BROKEN(width,gap,off,hex,ascii,space,expected) do { \
30 DO_HEXDUMP(off,hex,ascii,width,gap,space); \
31 TEST_EXPECT_EQUAL__BROKEN(str.get_data(), expected); \
37 char buf[] = { 0x11, 0x47, 0, 0};
40 TEST_HEXDUMP_EQUAL(0, 0,
false,
true,
false,
true,
"11 47 00 00\n");
41 TEST_HEXDUMP_EQUAL(0, 0,
false,
true,
false,
false,
"11470000\n");
42 TEST_HEXDUMP_EQUAL(0, 0,
false,
false,
true,
true,
".G..\n");
43 TEST_HEXDUMP_EQUAL(0, 0,
false,
true,
true,
true,
"11 47 00 00 | .G..\n");
45 TEST_HEXDUMP_EQUAL(0, 0,
true,
false,
true,
true,
"0000 | .G..\n");
46 TEST_HEXDUMP_EQUAL(0, 0,
true,
true,
false,
true,
"0000 | 11 47 00 00\n");
47 TEST_HEXDUMP_EQUAL(0, 0,
true,
true,
true,
true,
"0000 | 11 47 00 00 | .G..\n");
49 TEST_HEXDUMP_EQUAL(4, 0,
false,
true,
false,
true,
"11 47 00 00\n");
50 TEST_HEXDUMP_EQUAL(4, 0,
true,
true,
false,
true,
"0000 | 11 47 00 00\n");
51 TEST_HEXDUMP_EQUAL(4, 0,
true,
true,
true,
true,
"0000 | 11 47 00 00 | .G..\n");
53 TEST_HEXDUMP_EQUAL(3, 0,
false,
true,
false,
true,
"11 47 00\n00\n");
54 TEST_HEXDUMP_EQUAL(3, 0,
true,
true,
false,
true,
"0000 | 11 47 00\n0003 | 00\n");
55 TEST_HEXDUMP_EQUAL(3, 0,
true,
true,
true,
true,
"0000 | 11 47 00 | .G.\n0003 | 00 | .\n");
57 TEST_HEXDUMP_EQUAL(2, 0,
false,
true,
false,
true,
"11 47\n00 00\n");
58 TEST_HEXDUMP_EQUAL(2, 0,
true,
true,
false,
true,
"0000 | 11 47\n0002 | 00 00\n");
59 TEST_HEXDUMP_EQUAL(2, 0,
true,
true,
true,
true,
"0000 | 11 47 | .G\n0002 | 00 00 | ..\n");
61 TEST_HEXDUMP_EQUAL(1, 0,
false,
true,
false,
true,
"11\n47\n00\n00\n");
62 TEST_HEXDUMP_EQUAL(1, 0,
true,
true,
false,
true,
"0000 | 11\n0001 | 47\n0002 | 00\n0003 | 00\n");
63 TEST_HEXDUMP_EQUAL(1, 0,
true,
true,
true,
true,
"0000 | 11 | .\n0001 | 47 | G\n0002 | 00 | .\n0003 | 00 | .\n");
67 char buf[] =
"\1Smarkerline\1Sposvar_full_all\1Sp";
68 int len = strlen(buf);
69 TEST_HEXDUMP_EQUAL(16, 0,
true,
true,
true,
true,
70 "0000 | 01 53 6D 61 72 6B 65 72 6C 69 6E 65 01 53 70 6F | .Smarkerline.Spo\n"
71 "0010 | 73 76 61 72 5F 66 75 6C 6C 5F 61 6C 6C 01 53 70 | svar_full_all.Sp\n");
72 TEST_HEXDUMP_EQUAL(16, 4,
true,
true,
true,
true,
73 "0000 | 01 53 6D 61 72 6B 65 72 6C 69 6E 65 01 53 70 6F | .Sma rker line .Spo\n"
74 "0010 | 73 76 61 72 5F 66 75 6C 6C 5F 61 6C 6C 01 53 70 | svar _ful l_al l.Sp\n");
75 TEST_HEXDUMP_EQUAL(13, 4,
true,
true,
true,
true,
76 "0000 | 01 53 6D 61 72 6B 65 72 6C 69 6E 65 01 | .Sma rker line .\n"
77 "000D | 53 70 6F 73 76 61 72 5F 66 75 6C 6C 5F | Spos var_ full _\n"
78 "001A | 61 6C 6C 01 53 70 | all. Sp\n"
80 TEST_HEXDUMP_EQUAL(13, 4,
true,
false,
true,
true,
81 "0000 | .Sma rker line .\n"
82 "000D | Spos var_ full _\n"
#define TEST_PUBLISH(testfunction)