Skip to content

Instantly share code, notes, and snippets.

@henryobiaraije
Created May 19, 2023 20:56
Show Gist options
  • Save henryobiaraije/238232178920d3d4fcbb8bd721db3de4 to your computer and use it in GitHub Desktop.
Save henryobiaraije/238232178920d3d4fcbb8bd721db3de4 to your computer and use it in GitHub Desktop.
Writing unit test for the Calculator struct.
// Full tutorial here https://youtu.be/LJppDNH2CHI
#[cfg(test)]
mod test{
use crate::Calculator;
#[test]
fn test_addition(){
let mut calculator = Calculator::new();
calculator.set_result(4.0);
calculator.add([5.0,5.0].to_vec());
assert_eq!(14.0, calculator.get_result())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment