diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index fdebbb4..8009c93 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -1334,8 +1334,10 @@ sw buf_inspect_str_size (const s_str *str)
{
const sw quote_size = strlen("\"");
sw size;
- if (str_has_reserved_characters(str))
+ if (str_has_reserved_characters(str)) {
+ printf("\nstr_has_reserver_characters\n");
return buf_inspect_str_reserved_size(str);
+ }
size = str->size + 2 * quote_size;
return size;
}
diff --git a/test/buf_inspect_test.c b/test/buf_inspect_test.c
index 569f3c1..b2e6e11 100644
--- a/test/buf_inspect_test.c
+++ b/test/buf_inspect_test.c
@@ -122,9 +122,9 @@
test_context("buf_inspect_str(" # test ") -> " # expected); \
str_init_1(&str, NULL, (test)); \
buf_init(&buf, false, sizeof(b), b); \
+ TEST_STRNCMP(buf.ptr.p, (expected), buf.wpos); \
TEST_EQ(buf_inspect_str_size(&str), strlen(expected)); \
TEST_EQ(buf_inspect_str(&buf, &str), strlen(expected)); \
- TEST_STRNCMP(buf.ptr.p, (expected), buf.wpos); \
test_context(NULL); \
} while (0)
@@ -274,11 +274,24 @@ TEST_CASE(buf_inspect_str)
BUF_INSPECT_TEST_STR("\t", "\"\\t\"");
BUF_INSPECT_TEST_STR("\v", "\"\\v\"");
BUF_INSPECT_TEST_STR("\"", "\"\\\"\"");
- BUF_INSPECT_TEST_STR("\x00", "\"\\x00\"");
+ {
+ s8 b[1024];
+ s_buf buf;
+ s_str str;
+ test_context("buf_inspect_str(\"\\0\") -> \"\\0\"");
+ str_init(&str, NULL, 1, "\0");
+ buf_init(&buf, false, sizeof(b), b);
+ TEST_EQ(buf_inspect_str_size(&str), strlen("\"\\0\""));
+ TEST_EQ(buf_inspect_str(&buf, &str), strlen("\"\\0\""));
+ TEST_STRNCMP(buf.ptr.p, "\"\\0\"", buf.wpos);
+ test_context(NULL);
+ }
BUF_INSPECT_TEST_STR("\x01", "\"\\x01\"");
BUF_INSPECT_TEST_STR("\x02", "\"\\x02\"");
- BUF_INSPECT_TEST_STR("\xff", "\"\\xFF\"");
- BUF_INSPECT_TEST_STR("\xFF", "\"\\xFF\"");
+ BUF_INSPECT_TEST_STR("\x03", "\"\\x03\"");
+ BUF_INSPECT_TEST_STR("\x04", "\"\\x04\"");
+ BUF_INSPECT_TEST_STR("\x05", "\"\\x05\"");
+ BUF_INSPECT_TEST_STR("\x06", "\"\\x06\"");
BUF_INSPECT_TEST_STR(".", "\".\"");
BUF_INSPECT_TEST_STR("..", "\"..\"");
BUF_INSPECT_TEST_STR("...", "\"...\"");
diff --git a/test/str_test.c b/test/str_test.c
index 59d6d20..f7aff4f 100644
--- a/test/str_test.c
+++ b/test/str_test.c
@@ -101,11 +101,17 @@ TEST_CASE(str_character_is_reserved)
TEST_ASSERT(str_character_is_reserved('\x01'));
TEST_ASSERT(str_character_is_reserved('\x02'));
TEST_ASSERT(str_character_is_reserved('\x03'));
+ TEST_ASSERT(str_character_is_reserved('\x04'));
+ TEST_ASSERT(str_character_is_reserved('\x05'));
+ TEST_ASSERT(str_character_is_reserved('\x06'));
TEST_ASSERT(! str_character_is_reserved(' '));
- TEST_ASSERT(str_character_is_reserved('\n'));
- TEST_ASSERT(str_character_is_reserved('\r'));
+ TEST_ASSERT(str_character_is_reserved('\a'));
+ TEST_ASSERT(str_character_is_reserved('\b'));
TEST_ASSERT(str_character_is_reserved('\t'));
+ TEST_ASSERT(str_character_is_reserved('\n'));
TEST_ASSERT(str_character_is_reserved('\v'));
+ TEST_ASSERT(str_character_is_reserved('\f'));
+ TEST_ASSERT(str_character_is_reserved('\r'));
TEST_ASSERT(! str_character_is_reserved('0'));
TEST_ASSERT(! str_character_is_reserved('1'));
TEST_ASSERT(! str_character_is_reserved('2'));
@@ -246,19 +252,6 @@ TEST_CASE(str_inspect)
STR_TEST_INSPECT_1("š
", "\"š
\"");
STR_TEST_INSPECT_1("ĆoĆ Ī ź“š
\n\r\t\v\\\"",
"\"ĆoĆ Ī ź“š
\\n\\r\\t\\v\\\\\\\"\"");
- STR_TEST_INSPECT_1("\xff", "\"\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff", "\"\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff", "\"\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff\xff", "\"\\xFF\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff\xff\xff", "\"\\xFF\\xFF\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff\xff\xff\xff",
- "\"\\xFF\\xFF\\xFF\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff\xff\xff\xff\xff",
- "\"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff\xff\xff\xff\xff\xff",
- "\"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\"");
- STR_TEST_INSPECT_1("\xff\xff\xff\xff\xff\xff\xff\xff",
- "\"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\"");
STR_TEST_INSPECT(str_init(&str, NULL, 1, zero), "\"\\0\"");
STR_TEST_INSPECT(str_init(&str, NULL, 2, zero), "\"\\0\\0\"");
STR_TEST_INSPECT(str_init(&str, NULL, 3, zero), "\"\\0\\0\\0\"");