    @Test
    public void testReduce() {

        FluentIterator<Integer> t = fluent(repeat(10, 5));
        BinaryOperator<Integer> op = (a, b) -> a + b;
        int sum = t.reduce(op);
        assertEquals(50, sum);

        t = fluent(repeat(10, 5));
        BinaryOperator<Integer> mul = (a, b) -> a * b;
        int prod = t.reduce(mul);
        assertEquals(100000, prod);

        t = fluent(empty());
        prod = t.reduce(mul, 1);
        assertEquals(1, prod);

        t = fluent(of(1, 2, 3));
        FluentIterator<Integer> s = fluent(of(10, 20, 30, 40, 50));
        BiFunction<FluentIterator<Integer>, Integer, FluentIterator<Integer>> f = (z, x) -> z.map(a -> a * x);

        int result = t.reduce(f, s).reduce(op);
        assertEquals(900, result);
    }