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:
2026-01-19 08:01:27 +00:00
parent b287268919
commit b8c7b5e68b
4 changed files with 204 additions and 177 deletions

View 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);
}