Skip to content

Commit

Permalink
Fixed bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Er…
Browse files Browse the repository at this point in the history
…ror is now correctly detected.

Modified runjsontests.py to allow test that expect failure in jsoncpp test suite.
  • Loading branch information
blep committed May 1, 2011
1 parent 565a1f3 commit 9c98f22
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
- Added test to ensure that the escape sequence "\/" is corrected handled
by the parser.

* Bug fixes

- Bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Error is now correctly
detected.

* License

- See file LICENSE for details. Basically JsonCpp is now licensed under
Expand Down
4 changes: 2 additions & 2 deletions src/lib_json/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ Reader::readArray( Token &tokenStart )
{
ok = readToken( token );
}
bool badTokenType = ( token.type_ == tokenArraySeparator &&
token.type_ == tokenArrayEnd );
bool badTokenType = ( token.type_ != tokenArraySeparator &&
token.type_ != tokenArrayEnd );
if ( !ok || badTokenType )
{
return addErrorAndRecover( "Missing ',' or ']' in array declaration",
Expand Down
1 change: 1 addition & 0 deletions test/data/fail_test_array_01.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ 1 2 3]
4 changes: 2 additions & 2 deletions test/runjsontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def runAllTests( jsontest_executable_path, input_dir = None,
failed_tests = []
valgrind_path = use_valgrind and VALGRIND_CMD or ''
for input_path in tests + test_jsonchecker:
is_json_checker_test = input_path in test_jsonchecker
expect_failure = os.path.basename( input_path ).startswith( 'fail' )
is_json_checker_test = (input_path in test_jsonchecker) or expect_failure
print 'TESTING:', input_path,
options = is_json_checker_test and '--json-checker' or ''
pipe = os.popen( "%s%s %s %s" % (
Expand All @@ -58,7 +59,6 @@ def runAllTests( jsontest_executable_path, input_dir = None,
process_output = pipe.read()
status = pipe.close()
if is_json_checker_test:
expect_failure = os.path.basename( input_path ).startswith( 'fail' )
if expect_failure:
if status is None:
print 'FAILED'
Expand Down

0 comments on commit 9c98f22

Please sign in to comment.