use of cyclops.reactive.ReactiveSeq in project cyclops by aol.
the class ZippingTest method testUnzip4WithLimits.
@Test
public void testUnzip4WithLimits() {
Supplier<ReactiveSeq<Tuple4<Integer, String, Long, Character>>> s = () -> DuplicationTest.of(new Tuple4(1, "a", 2l, 'z'), new Tuple4(2, "b", 3l, 'y'), new Tuple4(3, "c", 4l, 'x'));
Tuple4<ReactiveSeq<Integer>, ReactiveSeq<String>, ReactiveSeq<Long>, ReactiveSeq<Character>> u1 = ReactiveSeq.unzip4(s.get());
assertTrue(u1._1().limit(1).toList().containsAll(Arrays.asList(1)));
assertTrue(u1._2().limit(2).toList().containsAll(asList("a", "b")));
assertTrue(u1._3().limit(3).toList().containsAll(asList(2l, 3l, 4l)));
assertTrue(u1._4().limit(4).toList().containsAll(asList('z', 'y', 'x')));
}
use of cyclops.reactive.ReactiveSeq in project cyclops by aol.
the class ZippingTest method testUnzip3WithLimits.
@Test
public void testUnzip3WithLimits() {
Supplier<ReactiveSeq<Tuple3<Integer, String, Long>>> s = () -> DuplicationTest.of(new Tuple3(1, "a", 2l), new Tuple3(2, "b", 3l), new Tuple3(3, "c", 4l));
Tuple3<ReactiveSeq<Integer>, ReactiveSeq<String>, ReactiveSeq<Long>> u1 = ReactiveSeq.unzip3(s.get());
assertTrue(u1._1().limit(1).toList().containsAll(Arrays.asList(1)));
assertTrue(u1._2().limit(2).toList().containsAll(asList("a", "b")));
assertTrue(u1._3().toList().containsAll(asList(2l, 3l, 4l)));
}
use of cyclops.reactive.ReactiveSeq in project cyclops by aol.
the class BaseSequenceTest method takeWhileInclusive.
@Test
public void takeWhileInclusive() {
assertThat(ReactiveSeq.of(1, 2, 3).takeWhileInclusive(i -> i < 0).toList(), equalTo(Arrays.asList(1)));
assertThat(ReactiveSeq.of(1, 2, 3).takeWhileInclusive(i -> i < 3).toList(), equalTo(Arrays.asList(1, 2, 3)));
assertThat(ReactiveSeq.<Integer>of().takeWhileInclusive(i -> i < 3).toList(), equalTo(Arrays.asList()));
assertThat(ReactiveSeq.range(1, 1_000_000).takeWhileInclusive(i -> i < 300_000).toList(), equalTo(ReactiveSeq.range(1, 300_001).toList()));
AtomicInteger count = new AtomicInteger(0);
int size = ReactiveSeq.range(1, 1_000_000).peek(i -> count.incrementAndGet()).takeWhileInclusive(i -> i < 300_000).toList().size();
assertThat(count.get(), equalTo(300_000));
assertThat(size, equalTo(300000));
}
use of cyclops.reactive.ReactiveSeq in project cyclops by aol.
the class BaseSequenceTest method takeWhile.
@Test
public void takeWhile() {
assertThat(ReactiveSeq.of(1, 2, 3).takeWhile(i -> i < 3).toList(), equalTo(Arrays.asList(1, 2)));
assertThat(ReactiveSeq.<Integer>of().takeWhile(i -> i < 3).toList(), equalTo(Arrays.asList()));
assertThat(ReactiveSeq.range(1, 1_000_000).takeWhile(i -> i < 300_000).toList(), equalTo(ReactiveSeq.range(1, 300_000).toList()));
AtomicInteger count = new AtomicInteger(0);
int size = ReactiveSeq.range(1, 1_000_000).peek(i -> count.incrementAndGet()).takeWhile(i -> i < 300_000).toList().size();
assertThat(count.get(), equalTo(300_000));
assertThat(size, equalTo(299999));
}
use of cyclops.reactive.ReactiveSeq in project cyclops by aol.
the class AsyncZippingTest method testUnzip4.
@Test
public void testUnzip4() {
Supplier<ReactiveSeq<Tuple4<Integer, String, Long, Character>>> s = () -> of(new Tuple4(1, "a", 2l, 'z'), new Tuple4(2, "b", 3l, 'y'), new Tuple4(3, "c", 4l, 'x'));
Tuple4<ReactiveSeq<Integer>, ReactiveSeq<String>, ReactiveSeq<Long>, ReactiveSeq<Character>> u1 = ReactiveSeq.unzip4(s.get());
assertTrue(u1._1().toList().containsAll(Arrays.asList(1, 2, 3)));
assertTrue(u1._2().toList().containsAll(asList("a", "b", "c")));
assertTrue(u1._3().toList().containsAll(asList(2l, 3l, 4l)));
assertTrue(u1._4().toList().containsAll(asList('z', 'y', 'x')));
}
Aggregations