1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![crate_name = "daysbetweendates"]
//! dbd (Days Between Dates) is a library that counts days of the dates which you gave.
pub mod date;
pub mod daysbetweendates;

#[cfg(test)]
mod tests {
    use crate::date::Date;
    use crate::daysbetweendates::day_count;
    #[test]
    fn it_works() {
        let result = day_count(Date::from([10, 12, 1998]), Date::from([1, 1, 1999]));
        assert_eq!(result, 22);
    }

    #[test]
    fn one_year() {
        let result = day_count(Date::from([10, 12, 1998]), Date::from([10, 12, 1999]));
        assert_eq!(result, 365);
    }
    #[test]
    fn one_year_with_leak() {
        let result = day_count(Date::from([1, 1, 2000]), Date::from([1, 1, 2001]));
        assert_eq!(result, 366);
    }
    #[test]
    fn one_last_day() {
        let result = day_count(Date::from([31, 12, 2000]), Date::from([1, 1, 2001]));
        assert_eq!(result, 1);
    }
}