Commit 052457d328713bc7fd190f75d70401a3c6d92550

Thomas de Grivel 2023-04-12T23:17:36

tests ok

diff --git a/test/buf_parse_test.c b/test/buf_parse_test.c
index 9ea93b4..dd0e5a2 100644
--- a/test/buf_parse_test.c
+++ b/test/buf_parse_test.c
@@ -638,20 +638,20 @@
   } while (0)
 
 #define BUF_PARSE_TEST_S_PROTOTYPE(bits)                               \
-  void buf_parse_test_s ## bits ## _binary ();                         \
-  void buf_parse_test_s ## bits ## _binary_negative ();                \
-  void buf_parse_test_s ## bits ## _decimal ();                        \
-  void buf_parse_test_s ## bits ## _decimal_negative ();               \
-  void buf_parse_test_s ## bits ## _hexadecimal ();                    \
-  void buf_parse_test_s ## bits ## _hexadecimal_negative ();           \
-  void buf_parse_test_s ## bits ## _octal ();                          \
-  void buf_parse_test_s ## bits ## _octal_negative ()
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _binary);                 \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _binary_negative);        \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _decimal);                \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _decimal_negative);       \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _hexadecimal);            \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _hexadecimal_negative);   \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _octal);                  \
+  TEST_CASE_PROTOTYPE(buf_parse_s ## bits ## _octal_negative)
 
 #define BUF_PARSE_TEST_U_PROTOTYPE(bits)                               \
-  void buf_parse_test_u ## bits ## _binary ();                         \
-  void buf_parse_test_u ## bits ## _decimal ();                        \
-  void buf_parse_test_u ## bits ## _hexadecimal ();                    \
-  void buf_parse_test_u ## bits ## _octal ()
+  TEST_CASE_PROTOTYPE(buf_parse_u ## bits ## _binary);                 \
+  TEST_CASE_PROTOTYPE(buf_parse_u ## bits ## _decimal);                \
+  TEST_CASE_PROTOTYPE(buf_parse_u ## bits ## _hexadecimal);            \
+  TEST_CASE_PROTOTYPE(buf_parse_u ## bits ## _octal)
 
 TEST_CASE_PROTOTYPE(buf_parse_bool);
 TEST_CASE_PROTOTYPE(buf_parse_call);
@@ -1127,7 +1127,7 @@ TEST_CASE(buf_parse_integer_bin)
 }
 TEST_CASE_END(buf_parse_integer_bin)
 
-TEST_CASE(buf_parse_test_integer_dec)
+TEST_CASE(buf_parse_integer_dec)
 {
   BUF_PARSE_TEST_NOT_INTEGER_UNSIGNED_DEC("A");
   BUF_PARSE_TEST_NOT_INTEGER_UNSIGNED_DEC("STR");
@@ -1138,7 +1138,7 @@ TEST_CASE(buf_parse_test_integer_dec)
 }
 TEST_CASE_END(buf_parse_integer_bin)
 
-TEST_CASE(buf_parse_test_integer_hex)
+TEST_CASE(buf_parse_integer_hex)
 {
   BUF_PARSE_TEST_NOT_INTEGER_UNSIGNED_HEX(" ");
   BUF_PARSE_TEST_NOT_INTEGER_UNSIGNED_HEX("H");
@@ -1151,7 +1151,7 @@ TEST_CASE(buf_parse_test_integer_hex)
 }
 TEST_CASE_END(buf_parse_integer_bin)
 
-TEST_CASE(buf_parse_test_integer_oct)
+TEST_CASE(buf_parse_integer_oct)
 {
   BUF_PARSE_TEST_NOT_INTEGER_UNSIGNED_OCT("8");
   BUF_PARSE_TEST_NOT_INTEGER_UNSIGNED_OCT("A");
diff --git a/test/buf_test.c b/test/buf_test.c
index d27ad23..ce88e0c 100644
--- a/test/buf_test.c
+++ b/test/buf_test.c
@@ -190,8 +190,8 @@ void buf_test ()
   TEST_CASE_RUN(buf_write_str);
   TEST_CASE_RUN(buf_peek_1);
   TEST_CASE_RUN(buf_peek_character_utf8);
-  buf_test_peek_s8 ();
-  buf_test_peek_s16 ();
+  TEST_CASE_RUN(buf_peek_s8);
+  TEST_CASE_RUN(buf_peek_s16);
   TEST_CASE_RUN(buf_peek_u8);
   TEST_CASE_RUN(buf_read_1);
   TEST_CASE_RUN(buf_read_f32);
@@ -442,7 +442,7 @@ TEST_CASE(buf_read_character_utf8)
 }
 TEST_CASE_END(buf_read_character_utf8)
 
-void buf_test_read_f32()
+TEST_CASE(buf_read_f32)
 {
   s8 b[16];
   s_buf buf;
@@ -570,7 +570,7 @@ TEST_CASE(buf_read_s16)
 }
 TEST_CASE_END(buf_read_s16)
 
-void buf_test_read_s32()
+TEST_CASE(buf_read_s32)
 {
   s8 b[16];
   s_buf buf;
@@ -600,7 +600,7 @@ void buf_test_read_s32()
 }
 TEST_CASE_END(buf_read_s16)
 
-void buf_test_read_s64()
+TEST_CASE(buf_read_s64)
 {
   s8 b[32];
   s_buf buf;
@@ -673,7 +673,7 @@ TEST_CASE(buf_read_u8)
 }
 TEST_CASE_END(buf_read_u8)
 
-void buf_test_read_u16()
+TEST_CASE(buf_read_u16)
 {
   s8 b[8];
   s_buf buf;
@@ -703,7 +703,7 @@ void buf_test_read_u16()
 }
 TEST_CASE_END(buf_read_u8)
 
-void buf_test_read_u32()
+TEST_CASE(buf_read_u32)
 {
   s8 b[16];
   s_buf buf;
@@ -733,7 +733,7 @@ void buf_test_read_u32()
 }
 TEST_CASE_END(buf_read_u8)
 
-void buf_test_read_u64()
+TEST_CASE(buf_read_u64)
 {
   s8 b[32];
   s_buf buf;
diff --git a/test/cfn_test.c b/test/cfn_test.c
index bdde3c1..9598714 100644
--- a/test/cfn_test.c
+++ b/test/cfn_test.c
@@ -39,6 +39,11 @@ void cfn_test ()
   TEST_CASE_RUN(cfn_apply);
 }
 
+bool cfn_test_not (bool a)
+{
+  return a ? false : true;
+}
+
 TEST_CASE(cfn_apply)
 {
   s_list *args;
@@ -147,12 +152,6 @@ TEST_CASE(cfn_link)
 }
 TEST_CASE_END(cfn_link)
 
-bool cfn_test_not (bool a)
-{
-  return a ? false : true;
-}
-TEST_CASE_END(cfn_link)
-
 TEST_CASE(cfn_prep_cif)
 {
   s_cfn a;
diff --git a/test/fact_test.c b/test/fact_test.c
index fae35d3..fa705bc 100644
--- a/test/fact_test.c
+++ b/test/fact_test.c
@@ -50,27 +50,12 @@ void fact_test_clean_3 (s_fact *fact)
   tag_delete((s_tag *) fact->object);
 }
 
-TEST_CASE(fact_init)
-{
-  s_tag sym[3];
-  s_fact fact;
-  tag_init_sym_1(sym, "A");
-  tag_init_sym_1(sym + 1, "B");
-  tag_init_sym_1(sym + 2, "C");
-  TEST_EQ(fact_init(&fact, sym, sym + 1, sym + 2), &fact);
-  TEST_EQ(fact.subject, sym);
-  TEST_EQ(fact.predicate, sym + 1);
-  TEST_EQ(fact.object, sym + 2);
-}
-TEST_CASE_END(fact_init)
-
 s_fact * fact_test_init_1 (s_fact *fact, const s8 *tag)
 {
   assert(fact);
   fact->subject = fact->predicate = fact->object = tag_new_1(tag);
   return fact;
 }
-TEST_CASE_END(fact_init)
 
 s_fact * fact_test_init_3 (s_fact *fact, const s8 *subject,
                            const s8 *predicate, const s8 *object)
@@ -81,6 +66,19 @@ s_fact * fact_test_init_3 (s_fact *fact, const s8 *subject,
   fact->object    = tag_new_1(object);
   return fact;
 }
+
+TEST_CASE(fact_init)
+{
+  s_tag sym[3];
+  s_fact fact;
+  tag_init_sym_1(sym, "A");
+  tag_init_sym_1(sym + 1, "B");
+  tag_init_sym_1(sym + 2, "C");
+  TEST_EQ(fact_init(&fact, sym, sym + 1, sym + 2), &fact);
+  TEST_EQ(fact.subject, sym);
+  TEST_EQ(fact.predicate, sym + 1);
+  TEST_EQ(fact.object, sym + 2);
+}
 TEST_CASE_END(fact_init)
 
 TEST_CASE(fact_inspect)
diff --git a/test/ident_test.c b/test/ident_test.c
index 9c8960b..037cd74 100644
--- a/test/ident_test.c
+++ b/test/ident_test.c
@@ -47,6 +47,13 @@ TEST_CASE_PROTOTYPE(ident_character_is_reserved);
 TEST_CASE_PROTOTYPE(ident_first_character_is_reserved);
 TEST_CASE_PROTOTYPE(ident_inspect);
 
+void ident_test ()
+{
+  TEST_CASE_RUN(ident_inspect);
+  TEST_CASE_RUN(ident_first_character_is_reserved);
+  TEST_CASE_RUN(ident_character_is_reserved);
+}
+
 TEST_CASE(ident_character_is_reserved)
 {
   IDENT_TEST_CHARACTER_IS_RESERVED('_', false);
@@ -97,14 +104,6 @@ TEST_CASE(ident_first_character_is_reserved)
 }
 TEST_CASE_END(ident_first_character_is_reserved)
 
-void ident_test ()
-{
-  TEST_CASE_RUN(ident_inspect);
-  TEST_CASE_RUN(ident_first_character_is_reserved);
-  TEST_CASE_RUN(ident_character_is_reserved);
-}
-TEST_CASE_END(ident_first_character_is_reserved)
-
 TEST_CASE(ident_inspect)
 {
   IDENT_TEST_INSPECT("", "_\"\"");
diff --git a/test/sym_test.c b/test/sym_test.c
index 44d9518..0c1d392 100644
--- a/test/sym_test.c
+++ b/test/sym_test.c
@@ -35,12 +35,24 @@ TEST_CASE_PROTOTYPE(sym_1);
 const s_sym * sym_test_1_test (const s8 *p);
 TEST_CASE_PROTOTYPE(sym_inspect);
 
-
 void sym_test ()
 {
   TEST_CASE_RUN(sym_1);
   TEST_CASE_RUN(sym_inspect);
 }
+
+const s_sym * sym_test_1_test (const s8 *p)
+{
+  uw len;
+  const s_sym *sym;
+  len = strlen(p);
+  TEST_ASSERT((sym = sym_1(p)));
+  TEST_EQ(sym->str.size, len);
+  TEST_EQ(strncmp(p, sym->str.ptr.p, len), 0);
+  TEST_EQ(sym_1(p), sym_1(p));
+  return sym;
+}
+
 TEST_CASE(sym_1)
 {
   const s_sym *mod;
@@ -93,19 +105,6 @@ TEST_CASE(sym_1)
 }
 TEST_CASE_END(sym_1)
 
-const s_sym * sym_test_1_test (const s8 *p)
-{
-  uw len;
-  const s_sym *sym;
-  len = strlen(p);
-  TEST_ASSERT((sym = sym_1(p)));
-  TEST_EQ(sym->str.size, len);
-  TEST_EQ(strncmp(p, sym->str.ptr.p, len), 0);
-  TEST_EQ(sym_1(p), sym_1(p));
-  return sym;
-}
-TEST_CASE_END(sym_1)
-
 TEST_CASE(sym_inspect)
 {
   SYM_TEST_INSPECT("", ":\"\"");
diff --git a/test/test.c b/test/test.c
index df6b62c..55045aa 100644
--- a/test/test.c
+++ b/test/test.c
@@ -21,6 +21,7 @@
 
 #define TEST_KO_MAX     10
 
+const char  *g_test_case_name = NULL;
 const char  *g_test_context = NULL;
 long         g_test_count = 0;
 long         g_test_ko = 0;