コード例 #1
0
 @Test
 public void testFindTempClosestToZero_WithPositiveAndNegativeTempsArrayList() {
   double arr[] = {3.0, 10.2, -20.4, 100.0, -5.3, 1.0, -200.9};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 1;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
コード例 #2
0
 @Test
 public void testFindTempClosestToZero_WithSingleElement() {
   double arr[] = {1};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 1;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(result, expected, 0.001);
 }
コード例 #3
0
 @Test
 public void testFindTempClosestToZero_WithEquallyCloseTempsArrayList() {
   double arr[] = {3.0, 10.2, -20.4, -1.0, -5.3, 1.0, -200.9};
   TemperatureSeriesAnalysis tsa = new TemperatureSeriesAnalysis(arr);
   double expected = 1.0;
   double result = tsa.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
コード例 #4
0
 @Test
 public void testFindTempClosestToZero_IsPositiveTempsArrayList() {
   double arr[] = {3, 10, 20, 100, 5, 1, 200};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 1;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
コード例 #5
0
 @Test
 public void testFindTempClosestToZero_WithZeroElement() {
   double arr[] = {3, 10, 0, 100, 5, 1, 200};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   double expected = 0;
   double result = temperatureSeriesAnalysis.findTempClosestToZero();
   assertEquals(expected, result, 0.001);
 }
コード例 #6
0
  @Test
  public void testFindTempClozestToZeroArrayWithEqualAbsValueElementsPositiveValueFirst() {
    double[] temperatureSeries = {-3.25, 3.1, -32, 5.03, -3.01, 3.002, 5.03, -3.002, -321.02};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 3.002;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
コード例 #7
0
  @Test
  public void testFindTempClozestToZeroArrayWithSeveralEqualAbsValueElements() {
    double[] temperatureSeries = {-3.25, 6.1, -32, 3.25, -3.401, -3.25, 5.03, -31.002, 3.25};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 3.25;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
コード例 #8
0
  @Test
  public void testFindTempClozestToZeroArrayWithZeroElement() {
    double[] temperatureSeries = {-3.25, 3.1, -32, 5.03, -3.01, 0.0, 5.03, 6.214, -321.02};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 0;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
コード例 #9
0
  @Test
  public void testFindTempClozestToZeroArrayWithNegativeElements() {
    double[] temperatureSeries = {-3.25, -3.1, -32, -5.03, -3.01};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = -3.01;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
コード例 #10
0
  @Test
  public void testFindTempClozestToZeroArrayWithPositiveElements() {
    double[] temperatureSeries = {3.25, 2.1, 32, 6.02, 2.01};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 2.01;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
コード例 #11
0
  @Test
  public void testFindTempClozestToZeroArrayWithSingleElement() {
    double[] temperatureSeries = {3.25};
    TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
    double expResult = 3.25;
    double actualResult = seriesAnalysis.findTempClosestToZero();

    assertEquals(expResult, actualResult, epsilon);
  }
コード例 #12
0
 @Test(expected = InputMismatchException.class)
 public void testFindTempClosestToZero_FailTempOutOfRange() {
   double arr[] = {-10, 0, 100, -274};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   temperatureSeriesAnalysis.findTempClosestToZero();
 }
コード例 #13
0
 @Test(expected = IllegalArgumentException.class)
 public void testFindTempClosestToZero_FailOnEmptyList() {
   double arr[] = {};
   TemperatureSeriesAnalysis temperatureSeriesAnalysis = new TemperatureSeriesAnalysis(arr);
   temperatureSeriesAnalysis.findTempClosestToZero();
 }
コード例 #14
0
 @Test(expected = IllegalArgumentException.class)
 public void testFindTempClozestToZeroFailOnEmptyList() {
   double[] temperatureSeries = {};
   TemperatureSeriesAnalysis seriesAnalysis = new TemperatureSeriesAnalysis(temperatureSeries);
   seriesAnalysis.findTempClosestToZero();
 }