tests2.rs (513B)
1 // Calculates the power of 2 using a bit shift. 2 // `1 << n` is equivalent to "2 to the power of n". 3 fn power_of_2(n: u8) -> u64 { 4 1 << n 5 } 6 7 fn main() { 8 // You can optionally experiment here. 9 } 10 11 #[cfg(test)] 12 mod tests { 13 use super::*; 14 15 #[test] 16 fn you_can_assert_eq() { 17 // TODO: Test the function `power_of_2` with some values. 18 assert_eq!(power_of_2(1), 2); 19 assert_eq!(power_of_2(1), 2); 20 assert_eq!(power_of_2(1), 2); 21 assert_eq!(power_of_2(1), 2); 22 } 23 }