package com.bbn.bue.common.primitives;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Created by rgabbard on 1/25/16.
 */
public class DoubleUtilsTest {

  private static final double EPSILON = 1e-6;

  @Test(expected = IllegalArgumentException.class)
  public void testBadBounds() {
    DoubleUtils.clip(2.0, -1.0);
  }

  @Test
  public void testClipping() {
    assertEquals(-2.0, DoubleUtils.clip(-5.0, 2.0), EPSILON);
    assertEquals(2.0, DoubleUtils.clip(5.0, 2.0), EPSILON);
    assertEquals(1.0, DoubleUtils.clip(1.0, 2.0), EPSILON);
  }
}

@@ -101,16 +101,59 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0A/**%0A *
@@ -612,12 +612,241 @@
 LON);%0A  
-%7D
+  assertEquals(-2.0, DoubleUtils.clip(Double.NEGATIVE_INFINITY, 2.0), EPSILON);%0A    assertEquals(2.0, DoubleUtils.clip(Double.POSITIVE_INFINITY, 2.0), EPSILON);%0A    assertTrue(Double.isNaN(DoubleUtils.clip(Double.NaN, 2.0)));%0A  %7D%0A
 %0A%7D%0A

Add clipping test cases for infinities and NaN