Browse Source

Update the test of the exercise `temperature_conv`

content-update
Augusto 3 years ago
parent
commit
0544507d19
  1. 15
      rust/tests/temperature_conv_test/src/main.rs

15
rust/tests/temperature_conv_test/src/main.rs

@ -8,13 +8,20 @@ fn eql(a: f64, b: f64) -> bool {
#[test]
fn test_f_to_c() {
println!("{}", fahrenheit_to_celsius(83.0));
assert!(eql(fahrenheit_to_celsius(20.0), -6.666666666666666));
assert!(eql(fahrenheit_to_celsius(83.0), 28.333333333333332));
let temp_f = 20.0;
println!("{}°F = {}°C", temp_f, fahrenheit_to_celsius(temp_f));
assert!(eql(fahrenheit_to_celsius(temp_f), -6.666666666666666));
let temp_f = 83.0;
println!("{}°F = {}°C", temp_f, fahrenheit_to_celsius(temp_f));
assert!(eql(fahrenheit_to_celsius(temp_f), 28.333333333333332));
}
#[test]
fn test_c_to_f() {
let temp_c = 27.0;
println!("{}°C = {}°F", temp_c, fahrenheit_to_celsius(temp_c));
assert!(eql(celsius_to_fahrenheit(27.0), 80.6));
assert!(eql(celsius_to_fahrenheit(0.0), 32.0))
let temp_c = 0.0;
println!("{}°C = {}°F", temp_c, fahrenheit_to_celsius(temp_c));
assert!(eql(celsius_to_fahrenheit(temp_c), 32.0))
}

Loading…
Cancel
Save