Skip to content

Commit 367d16d

Browse files
committed
Improve tests found by cargo-mutants
1 parent a9cd7dc commit 367d16d

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

.cargo/mutants.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exclude_re = [
2+
"Cursor<'a>::next", # timeout
3+
"year_width", # timeout
4+
"Flags::has_change_or_upper_case", # false positive
5+
"src/format/mod.rs:96:21: replace << with >>", # false positive
6+
]

src/tests/format.rs

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ fn test_format_month_name_abbr() {
149149
check_all(&times, "'%b'", &["'Jul'"]);
150150
check_all(&times, "'%1b'", &["'Jul'"]);
151151
check_all(&times, "'%6b'", &["' Jul'"]);
152+
check_all(&times, "'%##b'", &["'JUL'"]);
152153
check_all(&times, "'%-_#^6b'", &["'JUL'"]);
153154
check_all(&times, "'%-0^6b'", &["'JUL'"]);
154155
check_all(&times, "'%0_#6b'", &["' JUL'"]);
@@ -252,34 +253,34 @@ fn test_format_hour_24h_space() {
252253
#[rustfmt::skip]
253254
fn test_format_hour_12h_zero() {
254255
let times = [
255-
MockTime { hour: 13, ..Default::default() },
256+
MockTime { hour: 14, ..Default::default() },
256257
MockTime { hour: 0, ..Default::default() },
257258
];
258259

259-
check_all(&times, "'%I'", &["'01'", "'12'"]);
260-
check_all(&times, "'%1I'", &["'1'", "'12'"]);
261-
check_all(&times, "'%4I'", &["'0001'", "'0012'"]);
262-
check_all(&times, "'%-_I'", &["'1'", "'12'"]);
263-
check_all(&times, "'%-0I'", &["'1'", "'12'"]);
264-
check_all(&times, "'%0_I'", &["' 1'", "'12'"]);
265-
check_all(&times, "'%_0I'", &["'01'", "'12'"]);
260+
check_all(&times, "'%I'", &["'02'", "'12'"]);
261+
check_all(&times, "'%1I'", &["'2'", "'12'"]);
262+
check_all(&times, "'%4I'", &["'0002'", "'0012'"]);
263+
check_all(&times, "'%-_I'", &["'2'", "'12'"]);
264+
check_all(&times, "'%-0I'", &["'2'", "'12'"]);
265+
check_all(&times, "'%0_I'", &["' 2'", "'12'"]);
266+
check_all(&times, "'%_0I'", &["'02'", "'12'"]);
266267
}
267268

268269
#[test]
269270
#[rustfmt::skip]
270271
fn test_format_hour_12h_space() {
271272
let times = [
272-
MockTime { hour: 13, ..Default::default() },
273+
MockTime { hour: 14, ..Default::default() },
273274
MockTime { hour: 0, ..Default::default() },
274275
];
275276

276-
check_all(&times, "'%l'", &["' 1'", "'12'"]);
277-
check_all(&times, "'%1l'", &["'1'", "'12'"]);
278-
check_all(&times, "'%4l'", &["' 1'", "' 12'"]);
279-
check_all(&times, "'%-_l'", &["'1'", "'12'"]);
280-
check_all(&times, "'%-0l'", &["'1'", "'12'"]);
281-
check_all(&times, "'%0_l'", &["' 1'", "'12'"]);
282-
check_all(&times, "'%_0l'", &["'01'", "'12'"]);
277+
check_all(&times, "'%l'", &["' 2'", "'12'"]);
278+
check_all(&times, "'%1l'", &["'2'", "'12'"]);
279+
check_all(&times, "'%4l'", &["' 2'", "' 12'"]);
280+
check_all(&times, "'%-_l'", &["'2'", "'12'"]);
281+
check_all(&times, "'%-0l'", &["'2'", "'12'"]);
282+
check_all(&times, "'%0_l'", &["' 2'", "'12'"]);
283+
check_all(&times, "'%_0l'", &["'02'", "'12'"]);
283284
}
284285

285286
#[test]
@@ -709,17 +710,17 @@ fn test_format_percent() {
709710
#[rustfmt::skip]
710711
fn test_format_combination_date_time() {
711712
let times = [
712-
MockTime::new(1970, 1, 1, 0, 0, 0, 0, 4, 1, 0, false, 0, ""),
713-
MockTime::new(-1970, 1, 1, 0, 0, 0, 0, 4, 1, 0, false, 0, ""),
713+
MockTime::new(971, 1, 1, 0, 0, 0, 0, 4, 1, 0, false, 0, ""),
714+
MockTime::new(-971, 1, 1, 0, 0, 0, 0, 4, 1, 0, false, 0, ""),
714715
];
715716

716-
check_all(&times, "'%c'", &["'Thu Jan 1 00:00:00 1970'", "'Thu Jan 1 00:00:00 -1970'"]);
717-
check_all(&times, "'%1c'", &["'Thu Jan 1 00:00:00 1970'", "'Thu Jan 1 00:00:00 -1970'"]);
718-
check_all(&times, "'%30c'", &["' Thu Jan 1 00:00:00 1970'", "' Thu Jan 1 00:00:00 -1970'"]);
719-
check_all(&times, "'%-^_#30c'", &["' THU JAN 1 00:00:00 1970'", "' THU JAN 1 00:00:00 -1970'"]);
720-
check_all(&times, "'%-0^30c'", &["'000000THU JAN 1 00:00:00 1970'", "'00000THU JAN 1 00:00:00 -1970'"]);
721-
check_all(&times, "'%0_#30c'", &["' Thu Jan 1 00:00:00 1970'", "' Thu Jan 1 00:00:00 -1970'"]);
722-
check_all(&times, "'%_030c'", &["'000000Thu Jan 1 00:00:00 1970'", "'00000Thu Jan 1 00:00:00 -1970'"]);
717+
check_all(&times, "'%c'", &["'Thu Jan 1 00:00:00 0971'", "'Thu Jan 1 00:00:00 -0971'"]);
718+
check_all(&times, "'%1c'", &["'Thu Jan 1 00:00:00 0971'", "'Thu Jan 1 00:00:00 -0971'"]);
719+
check_all(&times, "'%30c'", &["' Thu Jan 1 00:00:00 0971'", "' Thu Jan 1 00:00:00 -0971'"]);
720+
check_all(&times, "'%-^_#30c'", &["' THU JAN 1 00:00:00 0971'", "' THU JAN 1 00:00:00 -0971'"]);
721+
check_all(&times, "'%-0^30c'", &["'000000THU JAN 1 00:00:00 0971'", "'00000THU JAN 1 00:00:00 -0971'"]);
722+
check_all(&times, "'%0_#30c'", &["' Thu Jan 1 00:00:00 0971'", "' Thu Jan 1 00:00:00 -0971'"]);
723+
check_all(&times, "'%_030c'", &["'000000Thu Jan 1 00:00:00 0971'", "'00000Thu Jan 1 00:00:00 -0971'"]);
723724
}
724725

725726
#[test]
@@ -751,17 +752,17 @@ fn test_format_combination_date() {
751752
#[rustfmt::skip]
752753
fn test_format_combination_iso_8601() {
753754
let times = [
754-
MockTime { year: 1234, month: 5, day: 6, ..Default::default() },
755-
MockTime { year: -1234, month: 5, day: 6, ..Default::default() },
755+
MockTime { year: 234, month: 5, day: 6, ..Default::default() },
756+
MockTime { year: -234, month: 5, day: 6, ..Default::default() },
756757
];
757758

758-
check_all(&times, "'%F'", &["'1234-05-06'", "'-1234-05-06'"]);
759-
check_all(&times, "'%1F'", &["'1234-05-06'", "'-1234-05-06'"]);
760-
check_all(&times, "'%12F'", &["' 1234-05-06'", "' -1234-05-06'"]);
761-
check_all(&times, "'%-^_#12F'", &["' 1234-05-06'", "' -1234-05-06'"]);
762-
check_all(&times, "'%-0^12F'", &["'001234-05-06'", "'0-1234-05-06'"]);
763-
check_all(&times, "'%0_#12F'", &["' 1234-05-06'", "' -1234-05-06'"]);
764-
check_all(&times, "'%_012F'", &["'001234-05-06'", "'0-1234-05-06'"]);
759+
check_all(&times, "'%F'", &["'0234-05-06'", "'-0234-05-06'"]);
760+
check_all(&times, "'%1F'", &["'0234-05-06'", "'-0234-05-06'"]);
761+
check_all(&times, "'%12F'", &["' 0234-05-06'", "' -0234-05-06'"]);
762+
check_all(&times, "'%-^_#12F'", &["' 0234-05-06'", "' -0234-05-06'"]);
763+
check_all(&times, "'%-0^12F'", &["'000234-05-06'", "'0-0234-05-06'"]);
764+
check_all(&times, "'%0_#12F'", &["' 0234-05-06'", "' -0234-05-06'"]);
765+
check_all(&times, "'%_012F'", &["'000234-05-06'", "'0-0234-05-06'"]);
765766
}
766767

767768
#[test]

0 commit comments

Comments
 (0)