Search in sources :

Example 1 with DoubleRange

use of org.apache.commons.lang.math.DoubleRange in project gatk-protected by broadinstitute.

the class ParamUtilsUnitTest method testInRangeSuccess.

@Test
public void testInRangeSuccess() {
    Assert.assertTrue(4 == ParamUtils.inRange(4L, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(4, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(new IntRange(3, 6), 4, "error"));
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(new DoubleRange(-3, 6), 4.1, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(0.0 == ParamUtils.inRange(0.0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0.0 == ParamUtils.inRange(new DoubleRange(-3, 6), 0.0, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(-1 == ParamUtils.inRange(-1L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(-1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(new IntRange(-3, 6), -1, "error"));
    Assert.assertTrue(-1.5 == ParamUtils.inRange(-1.5, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1.5 == ParamUtils.inRange(new DoubleRange(-3, 6), -1.5, "error"));
}
Also used : DoubleRange(org.apache.commons.lang.math.DoubleRange) IntRange(org.apache.commons.lang.math.IntRange) Test(org.testng.annotations.Test)

Example 2 with DoubleRange

use of org.apache.commons.lang.math.DoubleRange in project gatk by broadinstitute.

the class ParamUtilsUnitTest method testInRangeSuccess.

@Test
public void testInRangeSuccess() {
    Assert.assertTrue(4 == ParamUtils.inRange(4L, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(4, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4 == ParamUtils.inRange(new IntRange(3, 6), 4, "error"));
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, 3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(4.1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(4.1 == ParamUtils.inRange(new DoubleRange(-3, 6), 4.1, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(0.0 == ParamUtils.inRange(0.0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0.0 == ParamUtils.inRange(new DoubleRange(-3, 6), 0.0, "error"));
    Assert.assertTrue(0 == ParamUtils.inRange(0L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(0, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(0 == ParamUtils.inRange(new IntRange(-3, 6), 0, "error"));
    Assert.assertTrue(-1 == ParamUtils.inRange(-1L, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(-1, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1 == ParamUtils.inRange(new IntRange(-3, 6), -1, "error"));
    Assert.assertTrue(-1.5 == ParamUtils.inRange(-1.5, -3, 6, "Range calculation did not work properly"), "Did not return proper value");
    Assert.assertTrue(-1.5 == ParamUtils.inRange(new DoubleRange(-3, 6), -1.5, "error"));
}
Also used : DoubleRange(org.apache.commons.lang.math.DoubleRange) IntRange(org.apache.commons.lang.math.IntRange) Test(org.testng.annotations.Test)

Aggregations

DoubleRange (org.apache.commons.lang.math.DoubleRange)2 IntRange (org.apache.commons.lang.math.IntRange)2 Test (org.testng.annotations.Test)2