Skip to content

Commit 414a17b

Browse files
committed
Add a JSONTestSuite runner.
1 parent ee1d211 commit 414a17b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/run_extranl_suite.nim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import osproc, os, strutils, sequtils
2+
3+
# https://github.com/nst/JSONTestSuite
4+
# A comprehensive test suite for RFC 8259 compliant JSON parsers
5+
6+
let p = absolutePath("../JSONTestSuite/test_parsing/*")
7+
8+
for f in toSeq(os.walkFiles(p)):
9+
let
10+
what = f.split("/")[^1][0]
11+
cmd = "tests/run_test_jsony" & " " & f
12+
code = execCmd(cmd)
13+
var status =
14+
if code == 2:
15+
if what == 'y': "good "
16+
elif what == 'n': "fail "
17+
elif what == 'i': "good "
18+
else: "?"
19+
elif code == 1:
20+
if what == 'y': "fail "
21+
elif what == 'n': "good "
22+
elif what == 'i': "good "
23+
else: "?"
24+
else: "crash"
25+
echo "[", status, "] ", cmd

tests/run_test_jsony.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Rebuild with: nim c -d:release
2+
3+
import json
4+
import os
5+
6+
let fn = os.paramStr(1)
7+
8+
try:
9+
discard fn.readFile().parseJson()
10+
quit(2)
11+
except:
12+
quit(1)

0 commit comments

Comments
 (0)