Commit c7a498685bb91aef0ae6d50406074ec0b639fd72

Thomas de Grivel 2022-11-10T22:09:16

facts_with_test

diff --git a/test/facts_test.c b/test/facts_test.c
index 02d98f5..21c236c 100644
--- a/test/facts_test.c
+++ b/test/facts_test.c
@@ -12,6 +12,7 @@
  * THIS SOFTWARE.
  */
 #include <stdio.h>
+#include <unistd.h>
 #include "../libc3/buf.h"
 #include "../libc3/facts.h"
 #include "fact_test.h"
@@ -133,6 +134,8 @@ void facts_test_dump ()
   facts_dump(&facts, "facts_test_dump.facts");
   test_file_compare("facts_test_dump.facts",
                     "facts_test_dump.facts.expected");
+  if (g_test_last_ok)
+    unlink("facts_test_dump.facts");
   i = 0;
   while (p[i]) {
     fact_test_clean_1(fact + i);
@@ -264,6 +267,8 @@ void facts_test_log_add ()
   fclose(fp);
   test_file_compare("facts_test_log_add.facts",
                     "facts_test_log_add.facts.expected");
+  if (g_test_last_ok)
+    unlink("facts_test_log_add.facts");
 }
 
 void facts_test_log_remove ()
@@ -321,6 +326,8 @@ void facts_test_log_remove ()
   fclose(fp);
   test_file_compare("facts_test_log_remove.facts",
                     "facts_test_log_remove.facts.expected");
+  if (g_test_last_ok)
+    unlink("facts_test_log_remove.facts");
 }
 
 void facts_test_new_delete ()
diff --git a/test/facts_with_test.c b/test/facts_with_test.c
index 1dbbf21..e0f2ca6 100644
--- a/test/facts_with_test.c
+++ b/test/facts_with_test.c
@@ -113,13 +113,13 @@ void facts_with_test_ ()
   TAG_TEST_EQ(predicate.data.var, tag + 1);
   TAG_TEST_EQ(object.data.var, tag + 2);
   TEST_ASSERT(facts_with_cursor_next(&cursor));
-  TAG_TEST_EQ(subject.data.var, tag);
-  TAG_TEST_EQ(predicate.data.var, tag + 1);
-  TAG_TEST_EQ(object.data.var, tag + 3);
-  TEST_ASSERT(facts_with_cursor_next(&cursor));
   TAG_TEST_EQ(subject.data.var, tag + 5);
   TAG_TEST_EQ(predicate.data.var, tag + 1);
   TAG_TEST_EQ(object.data.var, tag + 2);
+  TEST_ASSERT(facts_with_cursor_next(&cursor));
+  TAG_TEST_EQ(subject.data.var, tag);
+  TAG_TEST_EQ(predicate.data.var, tag + 1);
+  TAG_TEST_EQ(object.data.var, tag + 3);
   TEST_ASSERT(! facts_with_cursor_next(&cursor));
   TEST_ASSERT(! facts_with_cursor_next(&cursor));
   facts_with_cursor_clean(&cursor);