Fix a bug with cut_range_bounds returning invalid RangeBounds
This commit is contained in:
parent
9e48363cc1
commit
c80c4459fb
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -108,7 +108,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "range_bounds_map"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"either",
|
||||
"itertools",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "range_bounds_map"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
authors = ["James Forster <james.forsterer@gmail.com>"]
|
||||
edition = "2021"
|
||||
description = """
|
||||
|
@ -1952,7 +1952,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
//only return valid range_bounds
|
||||
return CutResult {
|
||||
before_cut: result
|
||||
.before_cut
|
||||
.filter(|x| is_valid_range_bounds::<(Bound<&I>, Bound<&I>), I>(x)),
|
||||
inside_cut: result
|
||||
.inside_cut
|
||||
.filter(|x| is_valid_range_bounds::<(Bound<&I>, Bound<&I>), I>(x)),
|
||||
after_cut: result
|
||||
.after_cut
|
||||
.filter(|x| is_valid_range_bounds::<(Bound<&I>, Bound<&I>), I>(x)),
|
||||
};
|
||||
}
|
||||
|
||||
#[trivial]
|
||||
@ -2932,6 +2943,30 @@ mod tests {
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn cut_range_bounds_should_return_valid_ranges() {
|
||||
let result = cut_range_bounds(&(3..8), &(5..8));
|
||||
if let Some(x) = result.before_cut {
|
||||
assert!(is_valid_range_bounds(&cloned_bounds(x)));
|
||||
}
|
||||
if let Some(x) = result.inside_cut {
|
||||
assert!(is_valid_range_bounds(&cloned_bounds(x)));
|
||||
}
|
||||
if let Some(x) = result.after_cut {
|
||||
assert!(is_valid_range_bounds(&cloned_bounds(x)));
|
||||
}
|
||||
|
||||
let result = cut_range_bounds(&(3..8), &(3..5));
|
||||
if let Some(x) = result.before_cut {
|
||||
assert!(is_valid_range_bounds(&cloned_bounds(x)));
|
||||
}
|
||||
if let Some(x) = result.inside_cut {
|
||||
assert!(is_valid_range_bounds(&cloned_bounds(x)));
|
||||
}
|
||||
if let Some(x) = result.after_cut {
|
||||
assert!(is_valid_range_bounds(&cloned_bounds(x)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn touches_tests() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user