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 tofalse
assert_eq!(left, right)
andassert_ne!(left, right)
testing left and right expressions for equality and inequality respectively