@Test(expected = IllegalArgumentException.class) public void testFindTempsGreaterThenFailOnEmptyList() { double[] temperatureSeries = {}; double tempValue = 5; TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries); seriesAnalysis.findTempsGreaterThen(tempValue); }
@Test public void testFindTempsGreaterThen() { double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1}; TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr); double[] expected = {3.0, 10.2}; double[] result = tsa.findTempsGreaterThen(1.0); assertEquals(expected.length, result.length); for (int i = 0; i < expected.length; i++) assertEquals(expected[i], result[i], 0.001); }
@Test public void testFindTempsGreaterThenArrayWithElementsLessThenTempValue() { double[] temperatureSeries = {3.25, 5.03, 2.031, 23.01, 95.03, 4, 1.0421}; double tempValue = 103.25; TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries); double[] expResult = {}; double[] actualResult = seriesAnalysis.findTempsGreaterThen(tempValue); assertArrayEquals(expResult, actualResult, epsilon); }
@Test public void testFindTempsGreaterThenArrayWithSeveralElement() { double[] temperatureSeries = {3.25, 5.03, 2.031, 23.01, -95.03, 4, 1.021, 2.51}; double tempValue = 2.51; TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries); double[] expResult = {3.25, 5.03, 23.01, 4, 2.51}; double[] actualResult = seriesAnalysis.findTempsGreaterThen(tempValue); assertArrayEquals(expResult, actualResult, epsilon); }
@Test public void testFindTempsGreaterThenArrayWithSingleElement() { double[] temperatureSeries = {5.25}; double tempValue = 4; TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries); double[] expResult = {5.25}; double[] actualResult = seriesAnalysis.findTempsGreaterThen(tempValue); assertArrayEquals(expResult, actualResult, epsilon); }
@Test(expected = IllegalArgumentException.class) public void testFindTempsGreaterThen_onEmptyArray() { double arr[] = {}; TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr); tsa.findTempsGreaterThen(-5.1); }