-
Notifications
You must be signed in to change notification settings - Fork 72
Address edge cases and add tests #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,15 @@ | |
"\":{\"" SECOND_QUERY_KEY "\" : \"" COMPLETE_QUERY_KEY_ANSWER "\",}}" | ||
#define TRAILING_COMMA_AFTER_VALUE_LENGTH ( sizeof( TRAILING_COMMA_AFTER_VALUE ) - 1 ) | ||
|
||
#define MISSING_COMMA_AFTER_VALUE "{\"foo\":{}\"bar\":\"abc\"}" | ||
#define MISSING_COMMA_AFTER_VALUE_LENGTH ( sizeof( MISSING_COMMA_AFTER_VALUE ) - 1 ) | ||
|
||
#define MISSING_VALUE_AFTER_KEY "{\"foo\":{\"bar\":}}" | ||
#define MISSING_VALUE_AFTER_KEY_LENGTH ( sizeof( MISSING_VALUE_AFTER_KEY ) - 1 ) | ||
|
||
#define MISMATCHED_BRACKETS "{\"foo\":{\"bar\":\"xyz\"]}" | ||
#define MISMATCHED_BRACKETS_LENGTH ( sizeof( MISMATCHED_BRACKETS ) - 1 ) | ||
|
||
#define INCORRECT_OBJECT_SEPARATOR "{\"foo\": \"bar\"; \"bar\": \"foo\"}" | ||
#define INCORRECT_OBJECT_SEPARATOR_LENGTH ( sizeof( INCORRECT_OBJECT_SEPARATOR ) - 1 ) | ||
|
||
|
@@ -542,10 +551,26 @@ void test_JSON_Validate_Illegal_Documents( void ) | |
CUT_AFTER_COMMA_SEPARATOR_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( CUT_AFTER_KEY, | ||
CUT_AFTER_KEY_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( TRAILING_COMMA_AFTER_VALUE, | ||
TRAILING_COMMA_AFTER_VALUE_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( MISSING_COMMA_AFTER_VALUE, | ||
MISSING_COMMA_AFTER_VALUE_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( MISSING_VALUE_AFTER_KEY, | ||
MISSING_VALUE_AFTER_KEY_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( MISMATCHED_BRACKETS, | ||
MISMATCHED_BRACKETS_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( NUL_ESCAPE, NUL_ESCAPE_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONIllegalDocument, jsonStatus ); | ||
|
||
|
@@ -717,10 +742,6 @@ void test_JSON_Validate_Partial_Documents( void ) | |
jsonStatus = JSON_Validate( CUT_AFTER_OBJECT_START_MARKER, | ||
CUT_AFTER_OBJECT_START_MARKER_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONPartial, jsonStatus ); | ||
|
||
jsonStatus = JSON_Validate( CUT_AFTER_KEY, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the changes to the parser, a key without a value is considered illegal, not partial. The case is also covered by one of the new tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I put the test back with the other illegal tests. |
||
CUT_AFTER_KEY_LENGTH ); | ||
TEST_ASSERT_EQUAL( JSONPartial, jsonStatus ); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "NB" stand for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nota bene
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be esoteric for readers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use e.g. and i.e. often enough. I'll keep it.