Skip to content

Commit d3c15ba

Browse files
committed
parse-zoneinfo: move tests into tests module
1 parent f29c72d commit d3c15ba

File tree

1 file changed

+52
-54
lines changed

1 file changed

+52
-54
lines changed

parse-zoneinfo/src/line.rs

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -354,45 +354,6 @@ impl Weekday {
354354
}
355355
}
356356

357-
#[cfg(test)]
358-
#[test]
359-
fn weekdays() {
360-
assert_eq!(
361-
Weekday::calculate(1970, Month::January, 1),
362-
Weekday::Thursday
363-
);
364-
assert_eq!(
365-
Weekday::calculate(2017, Month::February, 11),
366-
Weekday::Saturday
367-
);
368-
assert_eq!(Weekday::calculate(1890, Month::March, 2), Weekday::Sunday);
369-
assert_eq!(Weekday::calculate(2100, Month::April, 20), Weekday::Tuesday);
370-
assert_eq!(Weekday::calculate(2009, Month::May, 31), Weekday::Sunday);
371-
assert_eq!(Weekday::calculate(2001, Month::June, 9), Weekday::Saturday);
372-
assert_eq!(Weekday::calculate(1995, Month::July, 21), Weekday::Friday);
373-
assert_eq!(Weekday::calculate(1982, Month::August, 8), Weekday::Sunday);
374-
assert_eq!(
375-
Weekday::calculate(1962, Month::September, 6),
376-
Weekday::Thursday
377-
);
378-
assert_eq!(
379-
Weekday::calculate(1899, Month::October, 14),
380-
Weekday::Saturday
381-
);
382-
assert_eq!(
383-
Weekday::calculate(2016, Month::November, 18),
384-
Weekday::Friday
385-
);
386-
assert_eq!(
387-
Weekday::calculate(2010, Month::December, 19),
388-
Weekday::Sunday
389-
);
390-
assert_eq!(
391-
Weekday::calculate(2016, Month::February, 29),
392-
Weekday::Monday
393-
);
394-
}
395-
396357
fn is_leap(year: i64) -> bool {
397358
// Leap year rules: years which are factors of 4, except those divisible
398359
// by 100, unless they are divisible by 400.
@@ -407,21 +368,6 @@ fn is_leap(year: i64) -> bool {
407368
year & 3 == 0 && (year % 25 != 0 || year & 15 == 0)
408369
}
409370

410-
#[cfg(test)]
411-
#[test]
412-
fn leap_years() {
413-
assert!(!is_leap(1900));
414-
assert!(is_leap(1904));
415-
assert!(is_leap(1964));
416-
assert!(is_leap(1996));
417-
assert!(!is_leap(1997));
418-
assert!(!is_leap(1997));
419-
assert!(!is_leap(1999));
420-
assert!(is_leap(2000));
421-
assert!(is_leap(2016));
422-
assert!(!is_leap(2100));
423-
}
424-
425371
impl DaySpec {
426372
/// Converts this day specification to a concrete date, given the year and
427373
/// month it should occur in.
@@ -1320,6 +1266,44 @@ impl<'a> Line<'a> {
13201266
mod tests {
13211267
use super::*;
13221268

1269+
#[test]
1270+
fn weekdays() {
1271+
assert_eq!(
1272+
Weekday::calculate(1970, Month::January, 1),
1273+
Weekday::Thursday
1274+
);
1275+
assert_eq!(
1276+
Weekday::calculate(2017, Month::February, 11),
1277+
Weekday::Saturday
1278+
);
1279+
assert_eq!(Weekday::calculate(1890, Month::March, 2), Weekday::Sunday);
1280+
assert_eq!(Weekday::calculate(2100, Month::April, 20), Weekday::Tuesday);
1281+
assert_eq!(Weekday::calculate(2009, Month::May, 31), Weekday::Sunday);
1282+
assert_eq!(Weekday::calculate(2001, Month::June, 9), Weekday::Saturday);
1283+
assert_eq!(Weekday::calculate(1995, Month::July, 21), Weekday::Friday);
1284+
assert_eq!(Weekday::calculate(1982, Month::August, 8), Weekday::Sunday);
1285+
assert_eq!(
1286+
Weekday::calculate(1962, Month::September, 6),
1287+
Weekday::Thursday
1288+
);
1289+
assert_eq!(
1290+
Weekday::calculate(1899, Month::October, 14),
1291+
Weekday::Saturday
1292+
);
1293+
assert_eq!(
1294+
Weekday::calculate(2016, Month::November, 18),
1295+
Weekday::Friday
1296+
);
1297+
assert_eq!(
1298+
Weekday::calculate(2010, Month::December, 19),
1299+
Weekday::Sunday
1300+
);
1301+
assert_eq!(
1302+
Weekday::calculate(2016, Month::February, 29),
1303+
Weekday::Monday
1304+
);
1305+
}
1306+
13231307
#[test]
13241308
fn last_monday() {
13251309
let dayspec = DaySpec::Last(Weekday::Monday);
@@ -1590,4 +1574,18 @@ mod tests {
15901574
existing: "Europe/Istanbul",
15911575
new: "Asia/Istanbul",
15921576
})));
1577+
1578+
#[test]
1579+
fn leap_years() {
1580+
assert!(!is_leap(1900));
1581+
assert!(is_leap(1904));
1582+
assert!(is_leap(1964));
1583+
assert!(is_leap(1996));
1584+
assert!(!is_leap(1997));
1585+
assert!(!is_leap(1997));
1586+
assert!(!is_leap(1999));
1587+
assert!(is_leap(2000));
1588+
assert!(is_leap(2016));
1589+
assert!(!is_leap(2100));
1590+
}
15931591
}

0 commit comments

Comments
 (0)