From 58a9b0cfe135f6a7a274c1717702c10ac0e7ee5b Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Tue, 4 Sep 2012 20:56:44 +0100 Subject: [PATCH] Make the test harness not segfault when a test fails (!) --- c/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/c/main.c b/c/main.c index bad8541..b71bcad 100644 --- 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(); -- 2.40.0