]> granicus.if.org Git - jq/commitdiff
Make the test harness not segfault when a test fails (!)
authorStephen Dolan <mu@netsoc.tcd.ie>
Tue, 4 Sep 2012 19:56:44 +0000 (20:56 +0100)
committerStephen Dolan <mu@netsoc.tcd.ie>
Tue, 4 Sep 2012 19:56:44 +0000 (20:56 +0100)
c/main.c

index bad85418c0ab42ba9b03afb349107741f730a64a..b71bcad5010710b9f1354b80a676569ddc9b7d3c 100644 (file)
--- a/c/main.c
+++ b/c/main.c
@@ -52,14 +52,16 @@ void run_tests() {
         printf("Insufficient results\n");
         pass = 0;
         break;
-      } else if (!jv_equal(expected, actual)) {
+      } else if (!jv_equal(jv_copy(expected), jv_copy(actual))) {
         printf("Expected ");
-        jv_dump(expected);
+        jv_dump(jv_copy(expected));
         printf(", but got ");
-        jv_dump(actual);
+        jv_dump(jv_copy(actual));
         printf("\n");
         pass = 0;
       }
+      jv_free(expected);
+      jv_free(actual);
     }
     if (pass) {
       jv extra = jq_next();