Assert yourself!

Unit testing provides the developer with a number of methods called assertion methods:

#[test] 
fn multiply() 
{ 
   assert_eq!(5, 2 * 3); 
} 

In the preceding code snippet, we use the assert_eq! (assert equal) macro. The first argument is the answer expected, and the second argument is what is being tested. If 2 * 3 = 5, then the assertion is true and passes the unit test.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset