Skip to content

Commit

Permalink
test: add test for conversion from KeyRange
Browse files Browse the repository at this point in the history
Signed-off-by: bsbds <[email protected]>
  • Loading branch information
bsbds committed Mar 27, 2024
1 parent 9ab551d commit daf09ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/utils/src/interval_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,9 @@ where
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Interval<T> {
/// Low value
low: T,
pub low: T,
/// high value
high: T,
pub high: T,
}

impl<T: Ord> Interval<T> {
Expand Down
12 changes: 12 additions & 0 deletions crates/xlineapi/src/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@ mod tests {
assert!(BytesAffine::new_key("abcd") < BytesAffine::new_unbounded());
assert_eq!(BytesAffine::new_unbounded(), BytesAffine::new_unbounded());
}

#[test]
fn convert_from_key_range_is_ok() {
let range0 = KeyRange::new("a", "e");
let range1 = KeyRange::new_one_key("f");
let interval0: Interval<BytesAffine> = range0.into();
let interval1: Interval<BytesAffine> = range1.into();
assert_eq!(interval0.low, BytesAffine::new_key("a"));
assert_eq!(interval0.high, BytesAffine::new_key("e"));
assert_eq!(interval1.low, BytesAffine::new_key("f"));
assert_eq!(interval1.high, BytesAffine::new_key("f\0"));
}
}

0 comments on commit daf09ff

Please sign in to comment.