Commit f1593987f708c357be5435babf282676706d82f2

Thomas de Grivel 2023-11-30T19:19:57

wip tests

diff --git a/libc3/buf.c b/libc3/buf.c
index 0188d18..a887c13 100644
--- a/libc3/buf.c
+++ b/libc3/buf.c
@@ -23,7 +23,8 @@
 void buf_clean (s_buf *buf)
 {
   assert(buf);
-  free(buf->ptr.p);
+  if (buf->free)
+    free(buf->ptr.p);
 }
 
 void buf_delete (s_buf *buf)
@@ -181,7 +182,7 @@ sw buf_ignore_spaces_but_newline (s_buf *buf)
 s_buf * buf_init (s_buf *buf, bool p_free, uw size, s8 *p)
 {
   assert(buf);
-  assert((!size || p) && (size || !p));
+  assert(p);
   buf->column = 0;
   buf->flush = NULL;
   buf->free = p_free;
diff --git a/test/buf_inspect_test.c b/test/buf_inspect_test.c
index 9f004e9..4322e67 100644
--- a/test/buf_inspect_test.c
+++ b/test/buf_inspect_test.c
@@ -197,7 +197,7 @@ TEST_CASE(buf_inspect_array)
   BUF_INSPECT_TEST_ARRAY("(U8){0}", "(U8) {0}");
   BUF_INSPECT_TEST_ARRAY("(U8){{0, 1}, {2, 3}}",
                          "(U8) {{0, 1}, {2, 3}}");
-  BUF_INSPECT_TEST_ARRAY("(U8) { { { 0 , 1 } , {2 , 3 } } , { { 4 , 5 } , { 6 , 7 } } } }",
+  BUF_INSPECT_TEST_ARRAY("(U8) { { { 0 , 1 } , {2 , 3 } } , { { 4 , 5 } , { 6 , 7 } } }",
                          "(U8) {{{0, 1}, {2, 3}}, {{4, 5}, {6, 7}}}");
 }
 TEST_CASE_END(buf_inspect_array)