コード例 #1
0
 @Test
 public void testSummaryStatistics() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -5.1};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   TempSummaryStatistics tss = tsa.summaryStatistics();
   double average = tsa.average();
   assertEquals(average, tss.getAvgTemp(), 0.001);
 }
コード例 #2
0
 @Test
 public void testTemperatureSeriesAnalysis() {
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis();
   TempSummaryStatistics tss = temperatureSeriesAnalysis.summaryStatistics();
   assertTrue(
       tss.getAvgTemp() == tss.getMinTemp()
           && tss.getAvgTemp() == tss.getMaxTemp()
           && tss.getAvgTemp() == tss.getDevTemp());
 }
コード例 #3
0
  @Test
  public void testSummaryStatisticsArrayWithTheSameElements() {
    double[] temperatureSeries = {-22.034, -22.034, -22.034, -22.034, -22.034, -22.034};
    double avg = -22.034;
    double dev = 0;
    double min = -22.034;
    double max = -22.034;
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    TempSummaryStatistics expResult = new TempSummaryStatistics(avg, dev, min, max);
    TempSummaryStatistics actualResult = seriesAnalysis.summaryStatistics();

    assertEquals(expResult, actualResult);
  }
コード例 #4
0
  @Test
  public void testSummaryStatisticsArrayWithDifferentElements() {
    double[] temperatureSeries = {-22.034, 2.4, 3.025, 5.023, 20.12, -5.031};
    double avg = 0.58383333;
    double dev = 12.6076597275;
    double min = -22.034;
    double max = 20.12;
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    TempSummaryStatistics expResult = new TempSummaryStatistics(avg, dev, min, max);
    TempSummaryStatistics actualResult = seriesAnalysis.summaryStatistics();

    assertEquals(expResult, actualResult);
  }
コード例 #5
0
 @Test(expected = IllegalArgumentException.class)
 public void testSummaryStatisticsFailOnEmptyList() {
   double[] temperatureSeries = {};
   TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
   seriesAnalysis.summaryStatistics();
 }