mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-13 12:06:04 +00:00
improve tests
This commit is contained in:
parent
2042c63c86
commit
bc626daec8
@ -180,13 +180,21 @@ fn iter_test() {
|
|||||||
fn test_not_found_by_index() {
|
fn test_not_found_by_index() {
|
||||||
let array = vec![1, 2, 3, 4, 5];
|
let array = vec![1, 2, 3, 4, 5];
|
||||||
let haystack = json!(array);
|
let haystack = json!(array);
|
||||||
let result = jsonpath::select(&haystack, "$.[6]");
|
|
||||||
|
let result = jsonpath::select(&haystack, "$.[4]").unwrap();
|
||||||
|
assert_eq!(result, vec![5]);
|
||||||
|
|
||||||
|
let result = jsonpath::select(&haystack, "$.[5]");
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_not_found_by_key() {
|
fn test_not_found_by_key() {
|
||||||
let haystack = json!({"asd": 1});
|
let haystack = json!({"asd": 1});
|
||||||
|
|
||||||
|
let result = jsonpath::select(&haystack, "$.asd").unwrap();
|
||||||
|
assert_eq!(result, vec![1]);
|
||||||
|
|
||||||
let result = jsonpath::select(&haystack, "$.aaa");
|
let result = jsonpath::select(&haystack, "$.aaa");
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user