rustlings

solving rustlings ft. dracuxan
git clone [email protected]:dracuxan/rustlings.git
Log | Files | Refs

tests1.rs (538B)


      1 // Tests are important to ensure that your code does what you think it should
      2 // do.
      3 
      4 fn is_even(n: i64) -> bool {
      5     n % 2 == 0
      6 }
      7 
      8 fn main() {
      9     // You can optionally experiment here.
     10 }
     11 
     12 #[cfg(test)]
     13 mod tests {
     14     // When writing unit tests, it is common to import everything from the outer
     15     // module (`super`) using a wildcard.
     16     use super::*;
     17 
     18     #[test]
     19     fn you_can_assert() {
     20         assert!(is_even(0));
     21         assert!(!is_even(-1));
     22         //      ^ You can assert `false` using the negation operator `!`.
     23     }
     24 }