@@ 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);
+ }
+}