~janbaudisch/aoc-2019

2c2a69a47ec864032f2aa07b74a7a39280d3c74f — Jan Baudisch 4 years ago 9623a26
day_01: add tests
1 files changed, 20 insertions(+), 0 deletions(-)

M day_01/src/main.rs
M day_01/src/main.rs => day_01/src/main.rs +20 -0
@@ 35,3 35,23 @@ fn calculate_fuel_recursive(mass: u32) -> u32 {

    fuel as u32 + calculate_fuel_recursive(fuel as u32)
}

#[cfg(test)]
mod tests {
    use super::{calculate_fuel, calculate_fuel_recursive};

    #[test]
    fn part_one() {
        assert_eq!(calculate_fuel(12), 2);
        assert_eq!(calculate_fuel(14), 2);
        assert_eq!(calculate_fuel(1969), 654);
        assert_eq!(calculate_fuel(100756), 33583);
    }

    #[test]
    fn part_two() {
        assert_eq!(calculate_fuel_recursive(14), 2);
        assert_eq!(calculate_fuel_recursive(1969), 966);
        assert_eq!(calculate_fuel_recursive(100756), 50346);
    }
}