Skip to content

Commit ccc8245

Browse files
authored
Merge pull request #67 from artichoke/lopopolo/cargo-mutants
Add tests for check format assertions
2 parents 3125c5a + 38bf55a commit ccc8245

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ tags
104104

105105
# Coverage files
106106
*.profraw
107+
108+
# cargo mutants
109+
mutants.out/
110+
mutants.out.old/

src/tests/format.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,29 @@ fn check_all(times: &[MockTime<'_>], format: &str, all_expected: &[&str]) {
2828
}
2929
}
3030

31+
#[test]
32+
#[should_panic]
33+
#[rustfmt::skip]
34+
fn test_check_format_panics_on_error() {
35+
let time = MockTime { year: 1111, ..Default::default() };
36+
37+
check_format(&time, "'%Y'", "'1112'");
38+
}
39+
40+
#[test]
41+
#[should_panic]
42+
#[rustfmt::skip]
43+
fn test_check_all_panics_on_error() {
44+
let times = [
45+
MockTime { year: -1111, ..Default::default() },
46+
MockTime { year: -11, ..Default::default() },
47+
MockTime { year: 1, ..Default::default() },
48+
MockTime { year: 1111, ..Default::default() },
49+
];
50+
51+
check_all(&times, "'%Y'", &["'-1111'", "'-0011'", "'0001'", "'1112'"]);
52+
}
53+
3154
#[test]
3255
#[rustfmt::skip]
3356
fn test_format_year_4_digits() {

0 commit comments

Comments
 (0)