add test for sensor_name and sensor_unit
All checks were successful
Unit Tests / Run Tests (push) Successful in 10s

This commit is contained in:
Travis Shears 2026-03-24 11:48:46 +01:00
parent 4b766f54ae
commit 113384b6ce
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
2 changed files with 25 additions and 2 deletions

View file

@ -14,8 +14,8 @@ pub type SensorReading {
SensorReading(sensor: Sensor, value: Float)
}
pub fn print_sensor_reading(reading: SensorReading) -> Nil {
let sensor_name = case reading.sensor {
pub fn sensor_name(sensor: Sensor) -> String {
case sensor {
Temperature -> "Temperature"
Humidity -> "Humidity"
Pressure -> "Pressure"
@ -23,6 +23,10 @@ pub fn print_sensor_reading(reading: SensorReading) -> Nil {
ParticalMatterTwoPointFive -> "Partical matter 2.5 micros or less"
ParticalMatterTen -> "Partical matter 10 microns or less"
}
}
pub fn print_sensor_reading(reading: SensorReading) -> Nil {
let sensor_name = sensor_name(reading.sensor)
io.println(sensor_name <> ": " <> float.to_string(reading.value))
}