File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ gen: lib/univalue_escapes.h $(GENBIN)
3333 @echo Updating $<
3434 $(AM_V_at )$(GENBIN ) > lib/univalue_escapes.h
3535
36- noinst_PROGRAMS = $(TESTS )
36+ noinst_PROGRAMS = $(TESTS ) test/test_json
3737
3838TEST_DATA_DIR =test
3939
@@ -42,6 +42,11 @@ test_unitester_LDADD = libunivalue.la
4242test_unitester_CXXFLAGS = -I$(top_srcdir ) /include -DJSON_TEST_SRC=\"$(srcdir ) /$(TEST_DATA_DIR ) \"
4343test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS )
4444
45+ test_test_json_SOURCES = test/test_json.cpp
46+ test_test_json_LDADD = libunivalue.la
47+ test_test_json_CXXFLAGS = -I$(top_srcdir ) /include
48+ test_test_json_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS )
49+
4550TEST_FILES = \
4651 $(TEST_DATA_DIR ) /fail10.json \
4752 $(TEST_DATA_DIR ) /fail11.json \
Original file line number Diff line number Diff line change 11unitester
2+ test_json
23
34* .trs
45* .log
Original file line number Diff line number Diff line change 1+ // Test program that can be called by the JSON test suite at
2+ // https://github.com/nst/JSONTestSuite.
3+ //
4+ // It reads JSON input from stdin and exits with code 0 if it can be parsed
5+ // successfully. It also pretty prints the parsed JSON value to stdout.
6+
7+ #include < iostream>
8+ #include < string>
9+ #include " univalue.h"
10+
11+ using namespace std ;
12+
13+ int main (int argc, char *argv[])
14+ {
15+ UniValue val;
16+ if (val.read (string (istreambuf_iterator<char >(cin),
17+ istreambuf_iterator<char >()))) {
18+ cout << val.write (1 /* prettyIndent */ , 4 /* indentLevel */ ) << endl;
19+ return 0 ;
20+ } else {
21+ cerr << " JSON Parse Error." << endl;
22+ return 1 ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments