Commit 839ccd7 1 parent 3f03bfd commit 839ccd7 Copy full SHA for 839ccd7
File tree 3 files changed +31
-1
lines changed
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)
33
33
@echo Updating $<
34
34
$(AM_V_at )$(GENBIN ) > lib/univalue_escapes.h
35
35
36
- noinst_PROGRAMS = $(TESTS )
36
+ noinst_PROGRAMS = $(TESTS ) test/test_json
37
37
38
38
TEST_DATA_DIR =test
39
39
@@ -42,6 +42,11 @@ test_unitester_LDADD = libunivalue.la
42
42
test_unitester_CXXFLAGS = -I$(top_srcdir ) /include -DJSON_TEST_SRC=\"$(srcdir ) /$(TEST_DATA_DIR ) \"
43
43
test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS )
44
44
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
+
45
50
TEST_FILES = \
46
51
$(TEST_DATA_DIR ) /fail10.json \
47
52
$(TEST_DATA_DIR ) /fail11.json \
Original file line number Diff line number Diff line change 1
1
unitester
2
+ test_json
2
3
3
4
* .trs
4
5
* .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