Skip to content
Snippets Groups Projects
Commit 84ccc3bd authored by Melanie Bruns's avatar Melanie Bruns
Browse files

Add tests for getMinimum

parent 0b176db5
No related branches found
No related tags found
1 merge request!160Add minimum used memory across all hosts to plot
Pipeline #
......@@ -25,6 +25,7 @@ import static org.junit.Assert.*;
public class ReportTest {
private static final String WRONG_MAXIMUM = "The maximum was computed or formatted incorrectly.";
private static final String WRONG_MINIMUM = "The minimum was computed or formatted incorrectly.";
private File outputFile;
private Report report;
......@@ -73,6 +74,24 @@ public class ReportTest {
assertEquals(WRONG_MAXIMUM, "100.3000", report.getMaximum(valuesWithMaxTwice));
}
@Test
public void testGetMinimumReturnsNaNForEmptyList(){
List<Double> values = new ArrayList<>();
assertEquals("For empty lists, NaN should be returned", "NaN", report.getMinimum(values));
}
@Test
public void testGetMinimumReturnsMinimum(){
final List<Double> values = Arrays.asList(3.0, -1.2, 100.0, 100.3, 0.07);
assertEquals(WRONG_MINIMUM, "-1.2000", report.getMinimum(values));
final List<Double> valuesWithNegativeMin = Arrays.asList(-3.0, -1.2, -100.0, -100.3, -0.07);
assertEquals(WRONG_MINIMUM, "-100.3000", report.getMinimum(valuesWithNegativeMin));
final List<Double> valuesWithSameNumberTwice = Arrays.asList(30.0, -1.2, 100.0, 100.3, -0.07, 100.0);
assertEquals(WRONG_MINIMUM, "-1.2000", report.getMinimum(valuesWithSameNumberTwice));
final List<Double> valuesWithMinTwice = Arrays.asList(30.0, 1.2, 100.0, 100.3, 0.07, 100.3, 0.07);
assertEquals(WRONG_MINIMUM, "0.0700", report.getMinimum(valuesWithMinTwice));
}
@After
public void cleanUp() {
SimScenario.reset();
......
  • Contributor

    SonarQube analysis reported no issues.

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment