use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatStreamTest method testRangeStep3.
@Test
public void testRangeStep3() {
Context context = BigFloat.context(20);
List<BigFloat> list = BigFloatStream.range(context.valueOf(0), context.valueOf(10), context.valueOf(3)).collect(Collectors.toList());
assertEquals(4, list.size());
assertEquals(true, list.contains(context.valueOf(0)));
assertEquals(true, list.contains(context.valueOf(3)));
assertEquals(true, list.contains(context.valueOf(6)));
assertEquals(true, list.contains(context.valueOf(9)));
assertEquals(0, BigFloatStream.range(context.valueOf(0), context.valueOf(-1), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(0, BigFloatStream.range(context.valueOf(0), context.valueOf(0), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(1, BigFloatStream.range(context.valueOf(0), context.valueOf(1), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(1, BigFloatStream.range(context.valueOf(0), context.valueOf(2), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(1, BigFloatStream.range(context.valueOf(0), context.valueOf(3), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(2, BigFloatStream.range(context.valueOf(0), context.valueOf(4), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(2, BigFloatStream.range(context.valueOf(0), context.valueOf(5), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(2, BigFloatStream.range(context.valueOf(0), context.valueOf(6), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(3, BigFloatStream.range(context.valueOf(0), context.valueOf(7), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(3, BigFloatStream.range(context.valueOf(0), context.valueOf(8), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(3, BigFloatStream.range(context.valueOf(0), context.valueOf(9), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(4, BigFloatStream.range(context.valueOf(0), context.valueOf(10), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(4, BigFloatStream.range(context.valueOf(0), context.valueOf(11), context.valueOf(3)).collect(Collectors.toList()).size());
assertEquals(4, BigFloatStream.range(context.valueOf(0), context.valueOf(12), context.valueOf(3)).collect(Collectors.toList()).size());
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatStreamTest method testRangeClosedDoubleStep3.
@Test
public void testRangeClosedDoubleStep3() {
Context context = BigFloat.context(20);
List<BigFloat> list = BigFloatStream.rangeClosed(0.0, 12.0, 3.0, context).collect(Collectors.toList());
assertEquals(5, list.size());
assertEquals(true, list.contains(context.valueOf(0)));
assertEquals(true, list.contains(context.valueOf(3)));
assertEquals(true, list.contains(context.valueOf(6)));
assertEquals(true, list.contains(context.valueOf(9)));
assertEquals(true, list.contains(context.valueOf(12)));
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatStreamTest method testRangeStepZero.
@Test(expected = IllegalArgumentException.class)
public void testRangeStepZero() {
Context context = BigFloat.context(20);
BigFloatStream.range(context.valueOf(0), context.valueOf(10), context.valueOf(0));
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatStreamTest method testRangeClosedStepZero.
@Test(expected = IllegalArgumentException.class)
public void testRangeClosedStepZero() {
Context context = BigFloat.context(20);
BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(10), context.valueOf(0));
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatStreamTest method testRangeClosedStepMinus1.
@Test
public void testRangeClosedStepMinus1() {
Context context = BigFloat.context(20);
List<BigFloat> list = BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(10), context.valueOf(-1)).collect(Collectors.toList());
assertList(list, 0, 0);
}
Aggregations