Search in sources :

Example 1 with LongToDoubleFunction

use of com.annimon.stream.function.LongToDoubleFunction in project Lightweight-Stream-API by aNNiMON.

the class MapToDoubleTest method testMapToDouble.

@Test
@SuppressWarnings("unchecked")
public void testMapToDouble() {
    DoubleStream stream = LongStream.rangeClosed(2, 4).mapToDouble(new LongToDoubleFunction() {

        @Override
        public double applyAsDouble(long value) {
            return value / 10d;
        }
    });
    assertThat(stream, DoubleStreamMatcher.elements(array(closeTo(0.2, 0.00001), closeTo(0.3, 0.00001), closeTo(0.4, 0.00001))));
}
Also used : DoubleStream(com.annimon.stream.DoubleStream) LongToDoubleFunction(com.annimon.stream.function.LongToDoubleFunction) Test(org.junit.Test)

Aggregations

DoubleStream (com.annimon.stream.DoubleStream)1 LongToDoubleFunction (com.annimon.stream.function.LongToDoubleFunction)1 Test (org.junit.Test)1