-
Notifications
You must be signed in to change notification settings - Fork 1k
add unit tests for json #2993
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
Merged
Merged
add unit tests for json #2993
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ed22a48
add unit tests for json
Jim8y e696ef7
fix ut
Jim8y 4994d0f
add ut cases for JString.
Jim8y 172337b
add invalid jpath tests
Jim8y 756fd8e
behavior of jboolean is kinda weird. i have:
Jim8y 91d821d
Merge branch 'master' into add-test-for-json
43b8bb0
Merge branch 'master' into add-test-for-json
shargon 7a8786b
Merge branch 'master' into add-test-for-json
f014617
fix test error
ec138ca
add more test
130313a
Merge branch 'master' into add-test-for-json
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -99,6 +99,75 @@ public void TestInvalidFormat() | |
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$..*")); | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("..book")); | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$..")); | ||
|
|
||
| // Test with an empty JSON Path | ||
| // Assert.ThrowsException<FormatException>(() => json.JsonPath("")); | ||
|
|
||
| // Test with only special characters | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("@#$%^&*()")); | ||
|
|
||
| // Test with unmatched brackets | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[")); | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book)]")); | ||
|
|
||
| // Test with invalid operators | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book=>2")); | ||
|
|
||
| // Test with incorrect field syntax | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.'book'")); | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.[book]")); | ||
|
|
||
| // Test with unexpected end of expression | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[?(@.price<")); | ||
|
|
||
| // Test with invalid array indexing | ||
| // Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book['one']")); | ||
| // Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[999]")); | ||
|
|
||
| // Test with invalid recursive descent | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$..*..author")); | ||
|
|
||
| // Test with nonexistent functions | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book.length()")); | ||
|
|
||
| // Test with incorrect use of wildcards | ||
| // Assert.ThrowsException<FormatException>(() => json.JsonPath("$.*.store")); | ||
|
|
||
| // Test with improper use of filters | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[?(@.price)]")); | ||
|
|
||
| // Test with mixing of valid and invalid syntax | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[*],$.invalid")); | ||
|
|
||
| // Test with invalid escape sequences | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[\\]")); | ||
|
|
||
| // Test with incorrect property access | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.'b?ook'")); | ||
|
|
||
| // Test with invalid use of wildcard in array index | ||
| // Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[*]")); | ||
|
|
||
| // Test with missing operators in filter expressions | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[?(@.price)]")); | ||
|
|
||
| // Test with incorrect boolean logic in filters | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[?(@.price AND @.title)]")); | ||
|
|
||
| // Test with nested filters without proper closure | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[?(@.price[?(@ < 10)])]")); | ||
|
|
||
| // Test with misplaced recursive descent operator | ||
| // Assert.ThrowsException<FormatException>(() => json.JsonPath("$..store..book")); | ||
|
|
||
| // Test with using JSONPath reserved keywords incorrectly | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("[email protected]")); | ||
|
|
||
| // Test with incorrect combinations of valid operators | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book..[0]")); | ||
|
|
||
| // Test with invalid script expressions (if supported) | ||
| Assert.ThrowsException<FormatException>(() => json.JsonPath("$.store.book[(@.length-1)]")); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When is used?
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.
TestSerializationAndDeserialization