Commit a4346a84e842886262a032ba1ab1a06663c954a4

Thomas de Grivel 2024-08-30T19:38:11

fix buf_inspect_var test

diff --git a/libkc3/struct.c b/libkc3/struct.c
index 7cbc1aa..920a93e 100644
--- a/libkc3/struct.c
+++ b/libkc3/struct.c
@@ -239,7 +239,7 @@ s_struct * struct_init_1 (s_struct *s, const char *p)
       struct_clean(&tmp);
     return NULL;
   }
-  if (true) {
+  if (false) {
     err_write_1("\nstruct_init_1: tmp = ");
     err_inspect_struct(&tmp);
     err_write_1("\n");
diff --git a/libkc3/var.c b/libkc3/var.c
index 2e617c9..d742c96 100644
--- a/libkc3/var.c
+++ b/libkc3/var.c
@@ -65,6 +65,7 @@ s_var * var_init_1 (s_var *var, const char *p)
     assert(! "var_init_1: invalid var");
     return NULL;
   }
+  *var = tmp;
   return var;
 }
 
diff --git a/test/inspect_test.c b/test/inspect_test.c
index 411ea2c..de8f058 100644
--- a/test/inspect_test.c
+++ b/test/inspect_test.c
@@ -189,12 +189,12 @@
     test_context(NULL);                                                \
   } while (0)
 
-#define INSPECT_TEST_VAR(test, expected)                             \
+#define INSPECT_TEST_VAR(test, expected)                               \
   do {                                                                 \
     s_var var_test;                                                    \
     s_str str_result;                                                  \
     test_context("inspect_var(" # test ") -> " # expected);            \
-    var_init_1(&var_test, (test));                                     \
+    TEST_EQ(var_init_1(&var_test, (test)), &var_test);                 \
     TEST_EQ(inspect_var(&var_test, &str_result), &str_result);         \
     TEST_STRNCMP(str_result.ptr.p, (expected), str_result.size);       \
     TEST_EQ(str_result.size, strlen(expected));                        \