diff options
-rw-r--r-- | tests/unit/core/test-core-string.cpp | 73 |
1 files changed, 29 insertions, 44 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp index 686c06edb..9812a2367 100644 --- a/tests/unit/core/test-core-string.cpp +++ b/tests/unit/core/test-core-string.cpp @@ -108,6 +108,13 @@ extern "C" STRCMP_EQUAL(__result, str); \ free (str); +#define WEE_HEX_DUMP(__result, __data, __size, __bytes_per_line, \ + __prefix, __suffix) \ + str = string_hex_dump (__data, __size, __bytes_per_line, \ + __prefix, __suffix); \ + STRCMP_EQUAL(__result, str); \ + free (str); + extern struct t_hashtable *string_hashtable_shared; TEST_GROUP(CoreString) @@ -1917,58 +1924,36 @@ TEST(CoreString, Hex_dump) POINTERS_EQUAL(NULL, string_hex_dump ("abc", 3, 0, NULL, NULL)); POINTERS_EQUAL(NULL, string_hex_dump ("abc", 0, 5, NULL, NULL)); - str = string_hex_dump ("abc", 3, 3, NULL, NULL); - STRCMP_EQUAL("61 62 63 a b c ", str); - - str = string_hex_dump ("abc", 3, 3, "", ""); - STRCMP_EQUAL("61 62 63 a b c ", str); - - str = string_hex_dump ("abc", 3, 3, "(( ", NULL); - STRCMP_EQUAL("(( 61 62 63 a b c ", str); - - str = string_hex_dump ("abc", 3, 3, NULL, " ))"); - STRCMP_EQUAL("61 62 63 a b c ))", str); - - str = string_hex_dump ("abc", 3, 3, "(( ", " ))"); - STRCMP_EQUAL("(( 61 62 63 a b c ))", str); - - str = string_hex_dump ("abc", 3, 5, NULL, NULL); - STRCMP_EQUAL("61 62 63 a b c ", str); - - str = string_hex_dump ("abc", 3, 10, NULL, NULL); - STRCMP_EQUAL("61 62 63 a b c ", str); - - str = string_hex_dump ("abc", 3, 2, NULL, NULL); - STRCMP_EQUAL("61 62 a b \n" + WEE_HEX_DUMP("61 62 63 a b c ", "abc", 3, 3, NULL, NULL); + WEE_HEX_DUMP("61 62 63 a b c ", "abc", 3, 3, "", ""); + WEE_HEX_DUMP("(( 61 62 63 a b c ", "abc", 3, 3, "(( ", NULL); + WEE_HEX_DUMP("61 62 63 a b c ))", "abc", 3, 3, NULL, " ))"); + WEE_HEX_DUMP("(( 61 62 63 a b c ))", "abc", 3, 3, "(( ", " ))"); + WEE_HEX_DUMP("61 62 63 a b c ", "abc", 3, 5, NULL, NULL); + WEE_HEX_DUMP("61 62 63 a b c ", + "abc", 3, 10, NULL, NULL); + WEE_HEX_DUMP("61 62 a b \n" "63 c ", - str); - - str = string_hex_dump (noel_utf8, strlen (noel_utf8), 5, NULL, NULL); - STRCMP_EQUAL("6E 6F C3 AB 6C n o . . l ", str); - - str = string_hex_dump (noel_utf8, strlen (noel_utf8), 2, NULL, NULL); - STRCMP_EQUAL("6E 6F n o \n" + "abc", 3, 2, NULL, NULL); + WEE_HEX_DUMP("6E 6F C3 AB 6C n o . . l ", + noel_utf8, strlen (noel_utf8), 5, NULL, NULL); + WEE_HEX_DUMP("6E 6F n o \n" "C3 AB . . \n" "6C l ", - str); - str = string_hex_dump (noel_utf8, strlen (noel_utf8), 2, "( ", NULL); - STRCMP_EQUAL("( 6E 6F n o \n" + noel_utf8, strlen (noel_utf8), 2, NULL, NULL); + WEE_HEX_DUMP("( 6E 6F n o \n" "( C3 AB . . \n" "( 6C l ", - str); - str = string_hex_dump (noel_utf8, strlen (noel_utf8), 2, "( ", " )"); - STRCMP_EQUAL("( 6E 6F n o )\n" + noel_utf8, strlen (noel_utf8), 2, "( ", NULL); + WEE_HEX_DUMP("( 6E 6F n o )\n" "( C3 AB . . )\n" "( 6C l )", - str); - - str = string_hex_dump (noel_iso, strlen (noel_iso), 5, NULL, NULL); - STRCMP_EQUAL("6E 6F EB 6C n o . l ", str); - - str = string_hex_dump (noel_iso, strlen (noel_iso), 2, NULL, NULL); - STRCMP_EQUAL("6E 6F n o \n" + noel_utf8, strlen (noel_utf8), 2, "( ", " )"); + WEE_HEX_DUMP("6E 6F EB 6C n o . l ", + noel_iso, strlen (noel_iso), 5, NULL, NULL); + WEE_HEX_DUMP("6E 6F n o \n" "EB 6C . l ", - str); + noel_iso, strlen (noel_iso), 2, NULL, NULL); } /* |