daysbetweendates/
lib.rs

1#![crate_name = "daysbetweendates"]
2//! dbd (Days Between Dates) is a library that counts days of the dates which you gave.
3pub mod date;
4pub mod daysbetweendates;
5
6#[cfg(test)]
7mod tests {
8    use crate::date::Date;
9    use crate::daysbetweendates::day_count;
10    #[test]
11    fn it_works() {
12        let result = day_count(Date::from([10, 12, 1998]), Date::from([1, 1, 1999]));
13        assert_eq!(result, 22);
14    }
15
16    #[test]
17    fn one_year() {
18        let result = day_count(Date::from([10, 12, 1998]), Date::from([10, 12, 1999]));
19        assert_eq!(result, 365);
20    }
21    #[test]
22    fn one_year_with_leak() {
23        let result = day_count(Date::from([1, 1, 2000]), Date::from([1, 1, 2001]));
24        assert_eq!(result, 366);
25    }
26    #[test]
27    fn one_last_day() {
28        let result = day_count(Date::from([31, 12, 2000]), Date::from([1, 1, 2001]));
29        assert_eq!(result, 1);
30    }
31}