summaryrefslogtreecommitdiffstats
path: root/jq_test.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2013-04-28 18:33:45 -0500
committerNicolas Williams <nico@cryptonector.com>2013-04-28 18:46:21 -0500
commit87e9c64003fdb13c629a3e0fbd3c6691a1967d7f (patch)
tree66fad4f19de10ac656998e3b6e7547a84d8f85cd /jq_test.c
parent925ec3751f3b407c17412b0fa04a84fe39c1e0b7 (diff)
Remove globals/make jq_init/next/teardown() an API
Diffstat (limited to 'jq_test.c')
-rw-r--r--jq_test.c9
1 files changed, 5 insertions, 4 deletions
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;
}