unit testing in Rust

Tests are Rust functions that verify that the non-test code is functioning in the expected manner. The bodies of test functions typically perform some setup, run the code we want to test, then assert whether the results are what we expect.
Most 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.
* In Rust 2018, your unit tests can return Result<()>, which lets you use ? in them! This can make them much more concise.
* To check functions that should panic under certain circumstances, use attribute #[should_panic]