Commit 5413d6a3281cd7d035b8489204fc72b3d6fbc044

Baptiste 2022-11-03T12:36:42

add test_file_compare

diff --git a/test/test.c b/test/test.c
index 81510e9..f574805 100644
--- a/test/test.c
+++ b/test/test.c
@@ -36,6 +36,25 @@ void test_context (const char *context)
   /* printf("test_context(%s)\n", context); */
 }
 
+int test_file_compare(const char *path_a, const char *path_b)
+{
+  FILE *f1 = fopen(path_a, "r");
+  FILE *f2 = fopen(path_b, "r");
+  char c1, c2;
+  if (f1 == NULL || f2 == NULL) {
+    return 1;
+  }
+  while ((c1 = fgetc(f1)) != EOF && (c2 = fgetc(f2)) != EOF) {
+    if (c1 != c2) {
+      return 1;
+    }
+  }
+  if (c1 != c2) {
+    return 1;
+  }
+  return 0;
+}
+
 void test_init (int argc, char **argv)
 {
   const char **t;