Skip to content

Commit

Permalink
tried seperating tests to the lib file due to some weird errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Greacko committed Nov 1, 2024
1 parent 653c429 commit d03130f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
40 changes: 0 additions & 40 deletions crates/thermocouple-converter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,44 +56,4 @@ pub fn voltage_to_celsius(voltage: f64) -> f64 {
}

return -1.0;
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn voltage_to_celsius_test1() {
//println!("Test 1: {}", voltage_to_celsius(20.644));
let result:f64 = voltage_to_celsius(20.644);
assert!(499.97 <= result && 500.0 >= result);
}

#[test]
fn voltage_to_celsius_test2() {
// println!("Test 2: {}", voltage_to_celsius(6.138));
let result:f64 = voltage_to_celsius(6.138);
assert!(150.01 <= result && 150.03 >= result);
}

#[test]
fn voltage_to_celsius_test3() {
// println!("Test 3: {}", voltage_to_celsius(0.039));
let result:f64 = voltage_to_celsius(0.039);
assert!(0.97 <= result && 0.98 >= result);
}

#[test]
fn voltage_to_celsius_test4() {
// println!("Test 4: {}", voltage_to_celsius(-0.778));
let result:f64 = voltage_to_celsius(-0.778);
assert!(-20.03 <= result && -20.01 >= result);
}

#[test]
fn voltage_to_celsius_test5() {
// println!("Test 5: {}", voltage_to_celsius(10.0));
let result:f64 = voltage_to_celsius(10.0);
assert!(246.1 <= result && 246.3 >= result);
}
}
41 changes: 41 additions & 0 deletions crates/thermocouple-converter/tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::voltage_to_celsius;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn voltage_to_celsius_test1() {
//println!("Test 1: {}", voltage_to_celsius(20.644));
let result:f64 = voltage_to_celsius(20.644);
assert!(499.97 <= result && 500.0 >= result);
}

#[test]
fn voltage_to_celsius_test2() {
// println!("Test 2: {}", voltage_to_celsius(6.138));
let result:f64 = voltage_to_celsius(6.138);
assert!(150.01 <= result && 150.03 >= result);
}

#[test]
fn voltage_to_celsius_test3() {
// println!("Test 3: {}", voltage_to_celsius(0.039));
let result:f64 = voltage_to_celsius(0.039);
assert!(0.97 <= result && 0.98 >= result);
}

#[test]
fn voltage_to_celsius_test4() {
// println!("Test 4: {}", voltage_to_celsius(-0.778));
let result:f64 = voltage_to_celsius(-0.778);
assert!(-20.03 <= result && -20.01 >= result);
}

#[test]
fn voltage_to_celsius_test5() {
// println!("Test 5: {}", voltage_to_celsius(10.0));
let result:f64 = voltage_to_celsius(10.0);
assert!(246.1 <= result && 246.3 >= result);
}
}

0 comments on commit d03130f

Please sign in to comment.