forked from dogecoin/dogecoin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dogecoin#30 from ryanofsky/test-driver
Add test driver for JSONTestSuite
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
unitester | ||
test_json | ||
|
||
*.trs | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Test program that can be called by the JSON test suite at | ||
// https://github.com/nst/JSONTestSuite. | ||
// | ||
// It reads JSON input from stdin and exits with code 0 if it can be parsed | ||
// successfully. It also pretty prints the parsed JSON value to stdout. | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include "univalue.h" | ||
|
||
using namespace std; | ||
|
||
int main (int argc, char *argv[]) | ||
{ | ||
UniValue val; | ||
if (val.read(string(istreambuf_iterator<char>(cin), | ||
istreambuf_iterator<char>()))) { | ||
cout << val.write(1 /* prettyIndent */, 4 /* indentLevel */) << endl; | ||
return 0; | ||
} else { | ||
cerr << "JSON Parse Error." << endl; | ||
return 1; | ||
} | ||
} |