Skip to content

Commit 369e1f6

Browse files
test: cover missed mutations in matches_requested_range and Bound::size
Add tests to catch mutations found by cargo-mutants: - Range with mismatched start should not match (catches && → || on line 33) - Suffix with non-zero start should match (catches - → + on line 35) - Assert Bound::size() returns the correct value
1 parent d4fde98 commit 369e1f6

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

src/headers/tests.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ mod content_range {
2020

2121
#[test]
2222
fn successful_bound() {
23-
assert!(Bound::new(10..=20, Some(50)).is_ok());
24-
assert!(Bound::new(10..=20, None).is_ok());
23+
let sized = Bound::new(10..=20, Some(50)).unwrap();
24+
assert_eq!(sized.size(), Some(50));
25+
assert_eq!(sized.range().start(), 10);
26+
assert_eq!(sized.range().end(), 20);
27+
28+
let unsized_ = Bound::new(10..=20, None).unwrap();
29+
assert_eq!(unsized_.size(), None);
2530
}
2631

2732
#[test]
@@ -192,6 +197,22 @@ mod content_range {
192197

193198
assert!(!content_range.matches_requested_range(range));
194199
}
200+
201+
#[test]
202+
fn range_start_mismatch_does_not_match() {
203+
let range = HttpRange::Range(OrderedRange::new(5..=20).unwrap());
204+
let content_range = HttpContentRange::Bound(Bound::new(10..=20, Some(50)).unwrap());
205+
206+
assert!(!content_range.matches_requested_range(range));
207+
}
208+
209+
#[test]
210+
fn suffix_with_nonzero_start_matches() {
211+
let range = HttpRange::Suffix(5);
212+
let content_range = HttpContentRange::Bound(Bound::new(15..=19, Some(20)).unwrap());
213+
214+
assert!(content_range.matches_requested_range(range));
215+
}
195216
}
196217
}
197218

0 commit comments

Comments
 (0)