-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into standardize-exception
- Loading branch information
Showing
4 changed files
with
550 additions
and
24 deletions.
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
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 |
---|---|---|
|
@@ -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.