From 87e9c64003fdb13c629a3e0fbd3c6691a1967d7f Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Sun, 28 Apr 2013 18:33:45 -0500 Subject: Remove globals/make jq_init/next/teardown() an API --- jq_test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'jq_test.c') diff --git a/jq_test.c b/jq_test.c index c9bdaef4..8b5ee2c2 100644 --- a/jq_test.c +++ b/jq_test.c @@ -41,6 +41,7 @@ static int skipline(const char* buf) { static void run_jq_tests() { char buf[4096]; int tests = 0, passed = 0, invalid = 0; + jq_state *jq = NULL; while (1) { if (!fgets(buf, sizeof(buf), testdata)) break; @@ -59,13 +60,13 @@ static void run_jq_tests() { fgets(buf, sizeof(buf), testdata); jv input = jv_parse(buf); if (!jv_is_valid(input)){ invalid++; continue; } - jq_init(bc, input); + jq_init(bc, input, &jq); while (fgets(buf, sizeof(buf), testdata)) { if (skipline(buf)) break; jv expected = jv_parse(buf); if (!jv_is_valid(expected)){ invalid++; continue; } - jv actual = jq_next(); + jv actual = jq_next(jq); if (!jv_is_valid(actual)) { jv_free(actual); printf("*** Insufficient results\n"); @@ -88,7 +89,7 @@ static void run_jq_tests() { jv_free(actual); } if (pass) { - jv extra = jq_next(); + jv extra = jq_next(jq); if (jv_is_valid(extra)) { printf("*** Superfluous result: "); jv_dump(extra, 0); @@ -98,7 +99,7 @@ static void run_jq_tests() { jv_free(extra); } } - jq_teardown(); + jq_teardown(&jq); bytecode_free(bc); passed+=pass; } -- cgit v1.2.3