mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-24 17:02:16 +00:00
close #35
This commit is contained in:
commit
b736c962d2
@ -439,9 +439,9 @@ fn walk<'a, F>(vec: &[&'a Value], tmp: &mut Vec<&'a Value>, fun: &F)
|
||||
|
||||
fn abs_index(n: isize, len: usize) -> usize {
|
||||
if n < 0_isize {
|
||||
(n + len as isize) as usize
|
||||
(n + len as isize).max(0) as usize
|
||||
} else {
|
||||
n as usize
|
||||
n.min(len as isize) as usize
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -602,6 +602,16 @@ fn range() {
|
||||
json!(["first", "second", "third", "forth", "fifth"]),
|
||||
json!(["first", "third"]),
|
||||
);
|
||||
select_and_then_compare(
|
||||
"$[-4:]",
|
||||
json!(["first", "second", "third"]),
|
||||
json!(["first", "second", "third"]),
|
||||
);
|
||||
select_and_then_compare(
|
||||
"$[:4]",
|
||||
json!(["first", "second", "third"]),
|
||||
json!(["first", "second", "third"]),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user