diff --git a/.github/workflows/test-codegen.yml b/.github/workflows/test-codegen.yml index 856e4d86..162f3866 100644 --- a/.github/workflows/test-codegen.yml +++ b/.github/workflows/test-codegen.yml @@ -8,7 +8,7 @@ on: value: rsonpath-test-documents artifact-path: description: Path to which the artifact should be extracted. - value: crates/rsonpath-lib/tests/documents + value: crates/rsonpath-test/tests/documents env: CARGO_TERM_COLOR: always @@ -57,5 +57,5 @@ jobs: uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: name: rsonpath-test-documents - path: crates/rsonpath-lib/tests/documents + path: crates/rsonpath-test/tests/documents retention-days: 1 diff --git a/Justfile b/Justfile index a7cc6ba4..e917d921 100644 --- a/Justfile +++ b/Justfile @@ -233,19 +233,15 @@ commit msg: # === HOOKS === -tmpdiff := if os() == "windows" { - `New-TemporaryFile` -} else { - `mktemp -t pre-commit-hook-diff-XXXXXXXX.$$` -} - [private] -hook-pre-commit: +hook-pre-commit: + #!/bin/sh + tmpdiff=$(mktemp -t pre-commit-hook-diff-XXXXXXXX.$$) just assert-benchmarks-committed - git diff --full-index --binary > {{tmpdiff}} + git diff --full-index --binary > $tmpdiff git stash -q --keep-index (just verify-fmt && just verify-check); \ - git apply --whitespace=nowarn < {{tmpdiff}} && git stash drop -q; rm {{tmpdiff}} + git apply --whitespace=nowarn < $tmpdiff}} && git stash drop -q; rm $tmpdiff [private] @hook-post-checkout: checkout-benchmarks diff --git a/crates/rsonpath-benchmarks b/crates/rsonpath-benchmarks index 14d89d55..a0f1466b 160000 --- a/crates/rsonpath-benchmarks +++ b/crates/rsonpath-benchmarks @@ -1 +1 @@ -Subproject commit 14d89d556fe67f071865337a48a66f295caeba68 +Subproject commit a0f1466b7b468cf4c95552621cc37a6f3a812d04 diff --git a/crates/rsonpath-lib/src/classification/memmem/shared/mask_32.rs b/crates/rsonpath-lib/src/classification/memmem/shared/mask_32.rs index eb553683..16337847 100644 --- a/crates/rsonpath-lib/src/classification/memmem/shared/mask_32.rs +++ b/crates/rsonpath-lib/src/classification/memmem/shared/mask_32.rs @@ -12,7 +12,7 @@ pub(crate) fn find_in_mask( let mut result = (previous_block | (first << 1)) & second; while result != 0 { let idx = result.trailing_zeros() as usize; - if input.is_member_match(offset + idx - 2, offset + idx + label_size - 3, label) { + if offset + idx > 1 && input.is_member_match(offset + idx - 2, offset + idx + label_size - 3, label) { return Some(offset + idx - 2); } result &= !(1 << idx); diff --git a/crates/rsonpath-lib/src/classification/memmem/shared/mask_64.rs b/crates/rsonpath-lib/src/classification/memmem/shared/mask_64.rs index 9376266d..6cee56fd 100644 --- a/crates/rsonpath-lib/src/classification/memmem/shared/mask_64.rs +++ b/crates/rsonpath-lib/src/classification/memmem/shared/mask_64.rs @@ -13,7 +13,7 @@ pub(crate) fn find_in_mask( while result != 0 { let idx = result.trailing_zeros() as usize; debug!("{offset} + {idx} - 2 to {offset} + {idx} + {label_size} - 3"); - if input.is_member_match(offset + idx - 2, offset + idx + label_size - 3, label) { + if offset + idx > 1 && input.is_member_match(offset + idx - 2, offset + idx + label_size - 3, label) { return Some(offset + idx - 2); } result &= !(1 << idx); diff --git a/crates/rsonpath-lib/tests/documents/toml/head_skip_for_curly.toml b/crates/rsonpath-lib/tests/documents/toml/head_skip_for_curly.toml new file mode 100644 index 00000000..3b299fb8 --- /dev/null +++ b/crates/rsonpath-lib/tests/documents/toml/head_skip_for_curly.toml @@ -0,0 +1,26 @@ +# Define the JSON input for all query test cases. +[input] +# Short description of the input structure. +description = "Object with an empty key." + # Set to true only if your specific test input is fully compressed (no extraneous whitespace). +is_compressed = false + +# Inline JSON document. +[input.source] +json_string = '{"":null}' + +# Define queries to test on the input. +[[queries]] + # Valid JSONPath query string. +query = '$..["{"]' +# Short descritpion of the query semantics. +description = "descendant search for a key equal to the curly brace" + +[queries.results] +# Number of expected matches. +count = 0 +# Byte locations of spans of all matches, in order. +spans = [] +# Stringified values of all matches, verbatim as in the input, +# in the same order as above. +nodes = [] \ No newline at end of file diff --git a/crates/rsonpath-lib/tests/documents/toml/head_skip_for_square.toml b/crates/rsonpath-lib/tests/documents/toml/head_skip_for_square.toml new file mode 100644 index 00000000..75a1ceae --- /dev/null +++ b/crates/rsonpath-lib/tests/documents/toml/head_skip_for_square.toml @@ -0,0 +1,26 @@ +# Define the JSON input for all query test cases. +[input] +# Short description of the input structure. +description = "List with an empty string." + # Set to true only if your specific test input is fully compressed (no extraneous whitespace). +is_compressed = false + +# Inline JSON document. +[input.source] +json_string = '[""]' + +# Define queries to test on the input. +[[queries]] + # Valid JSONPath query string. +query = '$..["["]' +# Short descritpion of the query semantics. +description = "descendant search for a key equal to the square brace" + +[queries.results] +# Number of expected matches. +count = 0 +# Byte locations of spans of all matches, in order. +spans = [] +# Stringified values of all matches, verbatim as in the input, +# in the same order as above. +nodes = [] \ No newline at end of file diff --git a/crates/rsonpath-lib/tests/end_to_end.rs b/crates/rsonpath-lib/tests/end_to_end.rs index 89310124..479677e7 100644 --- a/crates/rsonpath-lib/tests/end_to_end.rs +++ b/crates/rsonpath-lib/tests/end_to_end.rs @@ -1,4 +1,4 @@ -// a408cf20bda680a9005e3d0ce325e327 +// 9d6b9a42dabad16a52cf829a2df81b06 use pretty_assertions::assert_eq; use rsonpath::engine::{main::MainEngine, Compiler, Engine}; use rsonpath::input::*; @@ -22762,6 +22762,552 @@ fn large_wikidata_dump_properties_with_query_path_to_p7103_claims_p31_references Ok(()) } #[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 0u64, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![], "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec![]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 0u64, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![], "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec![]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 0u64, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![], "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_compressed_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec![]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 0u64, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![], "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_buffered_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec![]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 0u64, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![], "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_mmap_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec![]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 0u64, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![], "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn list_with_an_empty_string_with_query_descendant_search_for_a_key_equal_to_the_square_brace_with_owned_bytes_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document head_skip_for_square.toml running the query $..[\"[\"] (descendant search for a key equal to the square brace) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"[\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_square.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec![]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] fn list_with_mixed_atomic_integers_and_objects_compressed_with_query_select_all_elements_on_the_list_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { println ! ("on document compressed/heterogenous_list.toml running the query $.a.* (select all elements on the list) with Input impl BufferedInput and result mode ApproxSpanResult"); @@ -31212,10 +31758,556 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 1u64, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![31usize,], "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec!["45"]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 1u64, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![31usize,], "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec!["45"]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 1u64, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![31usize,], "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec!["45"]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 1u64, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![31usize,], "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec!["45"]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 1u64, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![31usize,], "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = unsafe { MmapInput::map_file(&json_file)? }; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec!["45"]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let result = engine.count(&input)?; + assert_eq!(result, 1u64, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.indices(&input, &mut result)?; + assert_eq!(result, vec![31usize,], "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result + .iter() + .map(|x| (x.span().start_idx(), x.span().end_idx())) + .collect(); + let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + assert_eq!(tups, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = OwnedBytes::new(&raw_json.as_bytes())?; + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.matches(&input, &mut result)?; + let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); + let utf8 = utf8.expect("valid utf8"); + let expected: Vec<&str> = vec!["45"]; + assert_eq!(utf8, expected, "result != expected"); + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_approx_span_result_using_main_engine( +) -> Result<(), Box> { + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + let input = BufferedInput::new(json_file); + let engine = MainEngine::compile_query(&jsonpath_query)?; + let mut result = vec![]; + engine.approximate_spans(&input, &mut result)?; + let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); + let expected: Vec<(usize, usize, usize)> = vec![(6usize, 35usize, 35usize)]; + assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); + for i in 0..tups.len() { + let upper_bound = expected[i]; + let actual = tups[i]; + assert_eq!(actual.0, upper_bound.0, "result start_idx() != expected start_idx()"); + assert!( + actual.1 >= upper_bound.1, + "result end_idx() < expected end_lower_bound ({} < {})", + actual.1, + upper_bound.1 + ); + assert!( + actual.1 <= upper_bound.2, + "result end_idx() > expected end_upper_bound ({} > {}", + actual.1, + upper_bound.2 + ); + } + Ok(()) +} +#[test] +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31224,23 +32316,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![31usize,], "result != expected"); + assert_eq!(result, vec![6usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31250,15 +32342,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + let expected: Vec<(usize, usize)> = vec![(6usize, 35usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31266,22 +32358,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec!["{\"c\":{\"d\":[42,43,44],\"b\":45}}"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(6usize, 35usize, 35usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31303,10 +32395,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31315,23 +32407,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![31usize,], "result != expected"); + assert_eq!(result, vec![6usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31341,15 +32433,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + let expected: Vec<(usize, usize)> = vec![(6usize, 35usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31357,22 +32449,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec!["{\"c\":{\"d\":[42,43,44],\"b\":45}}"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(6usize, 35usize, 35usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31394,10 +32486,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31406,23 +32498,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![31usize,], "result != expected"); + assert_eq!(result, vec![6usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31432,15 +32524,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + let expected: Vec<(usize, usize)> = vec![(6usize, 35usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31448,22 +32540,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec!["{\"c\":{\"d\":[42,43,44],\"b\":45}}"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31485,35 +32577,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![31usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31523,15 +32615,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31539,22 +32631,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31576,35 +32668,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![31usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31614,15 +32706,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31630,22 +32722,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(31usize, 33usize, 33usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31667,35 +32759,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![31usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31705,15 +32797,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(31usize, 33usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31721,22 +32813,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(6usize, 35usize, 35usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31758,10 +32850,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31770,23 +32862,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![6usize,], "result != expected"); + assert_eq!(result, vec![23usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31796,15 +32888,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(6usize, 35usize)]; + let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31812,22 +32904,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["{\"c\":{\"d\":[42,43,44],\"b\":45}}"]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(6usize, 35usize, 35usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31849,10 +32941,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31861,23 +32953,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![6usize,], "result != expected"); + assert_eq!(result, vec![23usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31887,15 +32979,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(6usize, 35usize)]; + let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31903,22 +32995,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["{\"c\":{\"d\":[42,43,44],\"b\":45}}"]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(6usize, 35usize, 35usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -31940,10 +33032,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31952,23 +33044,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![6usize,], "result != expected"); + assert_eq!(result, vec![23usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31978,15 +33070,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(6usize, 35usize)]; + let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -31994,22 +33086,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["{\"c\":{\"d\":[42,43,44],\"b\":45}}"]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![]; + let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32031,35 +33123,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 0u64, "result != expected"); + assert_eq!(result, 1u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![], "result != expected"); + assert_eq!(result, vec![23usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32069,15 +33161,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![]; + let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32085,22 +33177,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec![]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![]; + let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32122,35 +33214,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 0u64, "result != expected"); + assert_eq!(result, 1u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![], "result != expected"); + assert_eq!(result, vec![23usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32160,15 +33252,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![]; + let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32176,22 +33268,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec![]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![]; + let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32213,35 +33305,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 0u64, "result != expected"); + assert_eq!(result, 1u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![], "result != expected"); + assert_eq!(result, vec![23usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32251,15 +33343,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![]; + let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32267,22 +33359,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec![]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32304,11 +33396,11 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; @@ -32316,24 +33408,24 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![23usize,], "result != expected"); + assert_eq!(result, vec![176usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -32342,38 +33434,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; + let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec!["45"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32395,11 +33487,11 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; @@ -32407,24 +33499,24 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![23usize,], "result != expected"); + assert_eq!(result, vec![176usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -32433,38 +33525,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; + let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec!["45"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32486,11 +33578,11 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; @@ -32498,24 +33590,24 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![23usize,], "result != expected"); + assert_eq!(result, vec![176usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -32524,38 +33616,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; + let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec!["45"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32577,11 +33669,11 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; @@ -32589,24 +33681,24 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![23usize,], "result != expected"); + assert_eq!(result, vec![176usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -32615,38 +33707,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; + let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec!["45"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32668,11 +33760,11 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; @@ -32680,24 +33772,24 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![23usize,], "result != expected"); + assert_eq!(result, vec![176usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -32706,38 +33798,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; + let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec!["45"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(23usize, 25usize, 25usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32759,11 +33851,11 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; @@ -32771,24 +33863,24 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![23usize,], "result != expected"); + assert_eq!(result, vec![176usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -32797,38 +33889,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compresse .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(23usize, 25usize)]; + let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_compressed_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document compressed/atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/atomic_after_list.json")?; + println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..b")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec!["45"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(21usize, 202usize, 207usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32850,10 +33942,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32862,23 +33954,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![176usize,], "result != expected"); + assert_eq!(result, vec![21usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32888,15 +33980,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; + let expected: Vec<(usize, usize)> = vec![(21usize, 202usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32904,22 +33996,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected : Vec < & str > = vec ! ["{\n \"c\": {\n \"d\": [\n 42,\n 43,\n 44\n ],\n \"b\": 45\n }\n }" ,] ; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(21usize, 202usize, 207usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -32941,10 +34033,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32953,23 +34045,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![176usize,], "result != expected"); + assert_eq!(result, vec![21usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32979,15 +34071,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; + let expected: Vec<(usize, usize)> = vec![(21usize, 202usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -32995,22 +34087,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected : Vec < & str > = vec ! ["{\n \"c\": {\n \"d\": [\n 42,\n 43,\n 44\n ],\n \"b\": 45\n }\n }" ,] ; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(21usize, 202usize, 207usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33032,10 +34124,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33044,23 +34136,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![176usize,], "result != expected"); + assert_eq!(result, vec![21usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33070,15 +34162,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; + let expected: Vec<(usize, usize)> = vec![(21usize, 202usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_a_object_and_then_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a..b (select the 'a' object and then the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33086,22 +34178,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected : Vec < & str > = vec ! ["{\n \"c\": {\n \"d\": [\n 42,\n 43,\n 44\n ],\n \"b\": 45\n }\n }" ,] ; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33123,35 +34215,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![176usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33161,15 +34253,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33177,22 +34269,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33214,35 +34306,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![176usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33252,15 +34344,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33268,22 +34360,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(176usize, 178usize, 191usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33305,35 +34397,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![176usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33343,15 +34435,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(176usize, 178usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_atomic_integer_by_descendant_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..b (select the atomic integer by descendant) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..b")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33359,22 +34451,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["45"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(21usize, 202usize, 207usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33396,10 +34488,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33408,23 +34500,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![21usize,], "result != expected"); + assert_eq!(result, vec![133usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33434,15 +34526,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(21usize, 202usize)]; + let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33450,22 +34542,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected : Vec < & str > = vec ! ["{\n \"c\": {\n \"d\": [\n 42,\n 43,\n 44\n ],\n \"b\": 45\n }\n }" ,] ; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(21usize, 202usize, 207usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33487,10 +34579,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33499,23 +34591,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![21usize,], "result != expected"); + assert_eq!(result, vec![133usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33525,15 +34617,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(21usize, 202usize)]; + let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33541,22 +34633,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected : Vec < & str > = vec ! ["{\n \"c\": {\n \"d\": [\n 42,\n 43,\n 44\n ],\n \"b\": 45\n }\n }" ,] ; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(21usize, 202usize, 207usize)]; + let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33578,10 +34670,10 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33590,23 +34682,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![21usize,], "result != expected"); + assert_eq!(result, vec![133usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33616,15 +34708,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(21usize, 202usize)]; + let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_first_and_only_element_of_the_a_list_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0] (select the first and only element of the 'a' list) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0]")?; + println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33632,22 +34724,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected : Vec < & str > = vec ! ["{\n \"c\": {\n \"d\": [\n 42,\n 43,\n 44\n ],\n \"b\": 45\n }\n }" ,] ; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![]; + let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33669,35 +34761,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 0u64, "result != expected"); + assert_eq!(result, 1u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![], "result != expected"); + assert_eq!(result, vec![133usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33707,15 +34799,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![]; + let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33723,22 +34815,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec![]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![]; + let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33760,35 +34852,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 0u64, "result != expected"); + assert_eq!(result, 1u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![], "result != expected"); + assert_eq!(result, vec![133usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33798,15 +34890,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![]; + let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33814,22 +34906,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec![]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![]; + let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33851,35 +34943,35 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 0u64, "result != expected"); + assert_eq!(result, 1u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![], "result != expected"); + assert_eq!(result, vec![133usize,], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33889,15 +34981,15 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![]; + let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_fourth_element_of_the_deeply_nested_list_which_does_not_exist_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[3] (select the fourth element of the deeply nested list (which does not exist)) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[3]")?; + println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; @@ -33905,22 +34997,22 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec![]; + let expected: Vec<&str> = vec!["44"]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -33942,36 +35034,36 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_count_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_index_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![133usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -33980,38 +35072,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -34033,36 +35125,36 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_count_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_index_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![133usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -34071,38 +35163,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -34124,36 +35216,36 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![133usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -34162,38 +35254,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_and_last_element_of_the_deeply_nested_list_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_an_empty_key_compressed_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $.a[0].c.d[2] (select the third and last element of the deeply nested list) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$.a[0].c.d[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document compressed/head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/compressed/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_approx_span_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -34215,36 +35307,36 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_count_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_index_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![133usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_span_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -34253,38 +35345,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_buffered_input_and_nodes_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_buffered_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl BufferedInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl BufferedInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = BufferedInput::new(json_file); let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_approx_span_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -34306,36 +35398,36 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_count_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_index_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![133usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_span_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -34344,38 +35436,38 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_mmap_input_and_nodes_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_mmap_input_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl MmapInput and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl MmapInput and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let json_file = fs::File::open("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = unsafe { MmapInput::map_file(&json_file)? }; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_approx_span_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_approx_span_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode ApproxSpanResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode ApproxSpanResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.approximate_spans(&input, &mut result)?; let tups: Vec<(usize, usize)> = result.iter().map(|x| (x.start_idx(), x.end_idx())).collect(); - let expected: Vec<(usize, usize, usize)> = vec![(133usize, 135usize, 152usize)]; + let expected: Vec<(usize, usize, usize)> = vec![]; assert_eq!(tups.len(), expected.len(), "result.len() != expected.len()"); for i in 0..tups.len() { let upper_bound = expected[i]; @@ -34397,36 +35489,36 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_count_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_count_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode CountResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode CountResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let result = engine.count(&input)?; - assert_eq!(result, 1u64, "result != expected"); + assert_eq!(result, 0u64, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_index_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_index_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode IndexResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode IndexResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.indices(&input, &mut result)?; - assert_eq!(result, vec![133usize,], "result != expected"); + assert_eq!(result, vec![], "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_span_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_nodes_result_span_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult(Span)"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode NodesResult(Span)"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; @@ -34435,23 +35527,23 @@ fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_quer .iter() .map(|x| (x.span().start_idx(), x.span().end_idx())) .collect(); - let expected: Vec<(usize, usize)> = vec![(133usize, 135usize)]; + let expected: Vec<(usize, usize)> = vec![]; assert_eq!(tups, expected, "result != expected"); Ok(()) } #[test] -fn object_with_a_list_of_integers_followed_by_an_atomic_integer_member_with_query_select_the_third_element_of_each_list_only_the_deeply_nested_one_has_a_third_element_with_owned_bytes_and_nodes_result_using_main_engine( +fn object_with_an_empty_key_with_query_descendant_search_for_a_key_equal_to_the_curly_brace_with_owned_bytes_and_nodes_result_using_main_engine( ) -> Result<(), Box> { - println ! ("on document atomic_after_list.toml running the query $..*[2] (select the third element of each list (only the deeply nested one has a third element)) with Input impl OwnedBytes and result mode NodesResult"); - let jsonpath_query = JsonPathQuery::parse("$..*[2]")?; - let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/atomic_after_list.json")?; + println ! ("on document head_skip_for_curly.toml running the query $..[\"{{\"] (descendant search for a key equal to the curly brace) with Input impl OwnedBytes and result mode NodesResult"); + let jsonpath_query = JsonPathQuery::parse("$..[\"{\"]")?; + let raw_json = fs::read_to_string("../rsonpath-lib/tests/documents/json/head_skip_for_curly.json")?; let input = OwnedBytes::new(&raw_json.as_bytes())?; let engine = MainEngine::compile_query(&jsonpath_query)?; let mut result = vec![]; engine.matches(&input, &mut result)?; let utf8: Result, _> = result.iter().map(|x| str::from_utf8(x.bytes())).collect(); let utf8 = utf8.expect("valid utf8"); - let expected: Vec<&str> = vec!["44"]; + let expected: Vec<&str> = vec![]; assert_eq!(utf8, expected, "result != expected"); Ok(()) } diff --git a/crates/rsonpath-test-codegen/src/gen.rs b/crates/rsonpath-test-codegen/src/gen.rs index c237e21b..7cda9afb 100644 --- a/crates/rsonpath-test-codegen/src/gen.rs +++ b/crates/rsonpath-test-codegen/src/gen.rs @@ -33,7 +33,11 @@ pub(crate) fn generate_test_fns(files: &mut Files) -> Result(val: &D) -> impl Display +where + D: Display, +{ + let s = val.to_string(); + s.replace('{', "{{").replace('}', "}}") +} diff --git a/crates/rsonpath-test/Cargo.toml b/crates/rsonpath-test/Cargo.toml index a85f6122..b4e50c88 100644 --- a/crates/rsonpath-test/Cargo.toml +++ b/crates/rsonpath-test/Cargo.toml @@ -17,4 +17,4 @@ publish = false [build-dependencies] eyre = "0.6.8" md5 = "0.7.0" -rsonpath-test-codegen = { version = "0.8.0", path = "../rsonpath-test-codegen" } \ No newline at end of file +rsonpath-test-codegen = { version = "0.8.1", path = "../rsonpath-test-codegen" } \ No newline at end of file diff --git a/crates/rsonpath-test/README.md b/crates/rsonpath-test/README.md index e97d59bf..dfa605c4 100644 --- a/crates/rsonpath-test/README.md +++ b/crates/rsonpath-test/README.md @@ -1,8 +1,9 @@ # Just codegen -This crate is almost useless. +This crate should be used only for the declarative TOML tests. -It has no code in it except for the build script. The build script generates test cases for `rsonpath-lib` +It has no code in it except for the build script and the generated script. +The build script generates test cases for `rsonpath-lib` based on TOML files in `tests/documents` using `rsonpath-test-codegen`. This is needed for the following reasons: 1. `rsonpath-test-codegen` cannot also have a `build.rs` script to generate the tests, since it would need to build-depend on itself; diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 5ad76400..2e3f5041 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -265,9 +265,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "static_assertions"