MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / test_range_syntax_support

Function test_range_syntax_support

rust/tests/bplus_tree.rs:2076–2114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2074
2075#[test]
2076fn test_range_syntax_support() {
2077 let mut tree = BPlusTreeMap::new(16).unwrap();
2078 for i in 0..10 {
2079 tree.insert(i, format!("value{}", i));
2080 }
2081
2082 // Test different range syntaxes
2083 let range1: Vec<_> = tree.range(3..7).map(|(k, v)| (*k, v.clone())).collect();
2084 assert_eq!(
2085 range1,
2086 vec![
2087 (3, "value3".to_string()),
2088 (4, "value4".to_string()),
2089 (5, "value5".to_string()),
2090 (6, "value6".to_string())
2091 ]
2092 );
2093
2094 let range2: Vec<_> = tree.range(3..=7).map(|(k, v)| (*k, v.clone())).collect();
2095 assert_eq!(
2096 range2,
2097 vec![
2098 (3, "value3".to_string()),
2099 (4, "value4".to_string()),
2100 (5, "value5".to_string()),
2101 (6, "value6".to_string()),
2102 (7, "value7".to_string())
2103 ]
2104 );
2105
2106 let range3: Vec<_> = tree.range(5..).map(|(k, _v)| *k).collect();
2107 assert_eq!(range3, vec![5, 6, 7, 8, 9]);
2108
2109 let range4: Vec<_> = tree.range(..5).map(|(k, _v)| *k).collect();
2110 assert_eq!(range4, vec![0, 1, 2, 3, 4]);
2111
2112 let range5: Vec<_> = tree.range(..).map(|(k, _v)| *k).collect();
2113 assert_eq!(range5, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
2114}
2115
2116#[test]
2117fn test_range_syntax_with_excluded_bounds() {

Callers

nothing calls this directly

Calls 3

cloneMethod · 0.80
insertMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected