Unit Testing

  • Unit tests go into a tests mod with the #[cfg(test)] attribute

  • Test functions are marked with the #[test attribute

  • Tests fail when something in the test function panics

  • There are some helper macros:

    • assert!(expression) panics if expression evaluates to false
    • assert_eq!(left, right) and assert_ne!(left, right) testing left and right expressions for equality and inequality respectively