You've already forked book-exercises
finish testing
- convert project to a library by moving program logic into lib.rs - create ./tests to store integration tests - create ./common to store code we want shared across integration tests
This commit is contained in:
24
testing/tests/integration_tests.rs
Normal file
24
testing/tests/integration_tests.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use testing::ops::*;
|
||||
|
||||
mod common;
|
||||
|
||||
#[test]
|
||||
fn subtract_and_divide() {
|
||||
let a = 20;
|
||||
let b = 2;
|
||||
let c = 3;
|
||||
|
||||
let difference = sub(&a, &b);
|
||||
let quotient = div(&difference, &c);
|
||||
assert_eq!(quotient, 6);
|
||||
}
|
||||
#[test]
|
||||
fn add_and_multiply() {
|
||||
let a = 10;
|
||||
let b = common::give_me_5() as i32;
|
||||
let c = 3;
|
||||
|
||||
let sum = add(&a, &b);
|
||||
let product = mul(&sum, &c);
|
||||
assert_eq!(product, 45);
|
||||
}
|
||||
Reference in New Issue
Block a user