1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 13:56:37 +02:00

tests: fix memory leak in test of function string_hex_dump

This commit is contained in:
Sébastien Helleu
2020-05-31 14:51:41 +02:00
parent 527aa3c563
commit 8818fbb233
+29 -44
View File
@@ -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);
}
/*