-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic sanity check for range of measurement items.
- Loading branch information
Showing
4 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
sensor-data-bridge/src/test/java/nl/bertriksikken/pm/SensorDataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package nl.bertriksikken.pm; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public final class SensorDataTest { | ||
|
||
@Test | ||
public void testInRange() { | ||
SensorData sensorData = new SensorData(); | ||
|
||
// value in range | ||
Assert.assertTrue(sensorData.addValue(ESensorItem.HUMI, 100.0)); | ||
Assert.assertTrue(sensorData.hasValue(ESensorItem.HUMI)); | ||
Assert.assertEquals(100.0, sensorData.getValue(ESensorItem.HUMI), 0.1); | ||
|
||
// value out of range | ||
Assert.assertFalse(sensorData.addValue(ESensorItem.PM10, -1.0)); | ||
Assert.assertFalse(sensorData.hasValue(ESensorItem.PM10)); | ||
|
||
// invalid value | ||
Assert.assertFalse(sensorData.addValue(ESensorItem.PM2_5, Double.NaN)); | ||
Assert.assertFalse(sensorData.hasValue(ESensorItem.PM2_5)); | ||
} | ||
|
||
@Test | ||
public void testString() { | ||
SensorData sensorData = new SensorData(); | ||
String s = sensorData.toString(); | ||
Assert.assertEquals("{}", s); | ||
} | ||
|
||
} |