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 authored and Phoenix500526 committed Mar 28, 2024
1 parent f62e37b commit 4aab669
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/utils/src/interval_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,11 +980,12 @@ where
/// The Interval stored in `IntervalMap`
/// Represents the interval [low, high)
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[non_exhaustive]
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 4aab669

Please sign in to comment.