Add tests for the json_parse cli tool.

This commit is contained in:
Eric Hawicz
2026-06-21 13:44:59 -04:00
parent bb9c1238ad
commit d9d8cab822
4 changed files with 38 additions and 2 deletions
+8
View File
@@ -38,6 +38,10 @@ set(ALL_TEST_NAMES
test_visit
test_object_iterator)
set(NOBUILD_TEST_NAMES
test_json_parse_cli
)
if (NOT DISABLE_JSON_POINTER)
set(ALL_TEST_NAMES ${ALL_TEST_NAMES} test_json_pointer)
set(ALL_TEST_NAMES ${ALL_TEST_NAMES} test_safe_json_pointer_set)
@@ -46,6 +50,10 @@ if (NOT DISABLE_JSON_POINTER)
endif()
endif()
foreach(TESTNAME ${NOBUILD_TEST_NAMES})
add_test(NAME ${TESTNAME} COMMAND ${PROJECT_SOURCE_DIR}/tests/${TESTNAME}.test)
endforeach(TESTNAME)
foreach(TESTNAME ${ALL_TEST_NAMES})
add_executable(${TESTNAME} ${TESTNAME}.c)
+2
View File
@@ -0,0 +1,2 @@
Successfully parsed object from stdin
Failed at offset 71: invalid utf-8 string: char=0x00
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
# Common definitions
if test -z "$srcdir"; then
srcdir="${0%/*}"
test "$srcdir" = "$0" && srcdir=.
test -z "$srcdir" && srcdir=.
fi
. "$srcdir/test-defs.sh"
set -x -v
echo -n '"tenant=blue;note=CANARY_STACK_WINDOW_2026;status=ok"' > file1.dat
(printf '"' ; printf 'A%.0s' $(seq 1 16) ; echo 'e2' | xxd -r -p) > file2.dat
TESTNAME="${0##*/}"
TESTNAME="${TESTNAME%.test}"
( cat file1.dat ; cat file2.dat ) | run_output_test -o "${TESTNAME}" --exit 1 ../apps/json_parse -u -N -n -
_err=$?
exit $_err