Search in sources :

Example 6 with ExtendedRational

use of org.sosy_lab.common.rationals.ExtendedRational in project java-common-lib by sosy-lab.

the class ExtendedRationalTest method testIsRationalNumber.

@Test
public void testIsRationalNumber() {
    ExtendedRational x = new ExtendedRational(Rational.ofLongs(23, 7));
    assertThat(x.isRational()).isTrue();
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 7 with ExtendedRational

use of org.sosy_lab.common.rationals.ExtendedRational in project java-common-lib by sosy-lab.

the class ExtendedRationalTest method testOfStringInfty.

@Test
public void testOfStringInfty() {
    ExtendedRational a = ExtendedRational.ofString("Infinity");
    assertThat(a).isEqualTo(ExtendedRational.INFTY);
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 8 with ExtendedRational

use of org.sosy_lab.common.rationals.ExtendedRational in project java-common-lib by sosy-lab.

the class ExtendedRationalTest method testAdditionNaN.

@Test
public void testAdditionNaN() {
    ExtendedRational a = new ExtendedRational(Rational.ofLongs(12, 8));
    ExtendedRational b = ExtendedRational.NaN;
    assertThat(a.plus(b)).isEqualTo(ExtendedRational.NaN);
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 9 with ExtendedRational

use of org.sosy_lab.common.rationals.ExtendedRational in project java-common-lib by sosy-lab.

the class ExtendedRationalTest method testMultiplication1.

@Test
public void testMultiplication1() {
    ExtendedRational a = ExtendedRational.ofString("2/4");
    ExtendedRational b = ExtendedRational.ofString("-1/3");
    assertThat(a.times(b)).isEqualTo(new ExtendedRational(Rational.ofLongs(-2, 12)));
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 10 with ExtendedRational

use of org.sosy_lab.common.rationals.ExtendedRational in project java-common-lib by sosy-lab.

the class ExtendedRationalTest method testOfStringNaN.

@Test
public void testOfStringNaN() {
    ExtendedRational a = ExtendedRational.ofString("NaN");
    assertThat(a).isEqualTo(ExtendedRational.NaN);
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 ExtendedRational (org.sosy_lab.common.rationals.ExtendedRational)23 Var (com.google.errorprone.annotations.Var)2