Search in sources :

Example 11 with ExtendedRational

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

the class ExtendedRationalTest method testGetRational.

@Test
public void testGetRational() {
    ExtendedRational a = ExtendedRational.ofString("3/4");
    assertThat(a.getRational()).isEqualTo(Rational.ofString("3/4"));
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 12 with ExtendedRational

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

the class ExtendedRationalTest method testOfStringNumber.

@Test
public void testOfStringNumber() {
    ExtendedRational a = ExtendedRational.ofString("-2");
    Assert.assertEquals(new ExtendedRational(Rational.ofLong(-2)), a);
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 13 with ExtendedRational

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

the class ExtendedRationalTest method testInstantiation.

@Test
public void testInstantiation() {
    ExtendedRational x;
    x = new ExtendedRational(Rational.ofLongs(108, 96));
    Assert.assertEquals("9/8", x.toString());
    assertThat(x.toString()).isEqualTo("9/8");
}
Also used : ExtendedRational(org.sosy_lab.common.rationals.ExtendedRational) Test(org.junit.Test)

Example 14 with ExtendedRational

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

the class ExtendedRationalTest method testAdditionNumbers.

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

Example 15 with ExtendedRational

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

the class ExtendedRationalTest method testAdditionNegInfty.

@Test
public void testAdditionNegInfty() {
    ExtendedRational a = ExtendedRational.ofString("2309820938409238490");
    ExtendedRational b = ExtendedRational.NEG_INFTY;
    assertThat(a.plus(b)).isEqualTo(ExtendedRational.NEG_INFTY);
}
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