示例#1
0
  public void testMap() {
    assertCountSum(StreamSupport.stream(countTo(0)).map(mId), 0, 0);
    assertCountSum(StreamSupport.stream(countTo(10)).map(mId), 10, 55);
    assertCountSum(StreamSupport.stream(countTo(10)).map(mZero), 10, 0);
    assertCountSum(StreamSupport.stream(countTo(0)).map(mDoubler), 0, 0);
    assertCountSum(StreamSupport.stream(countTo(10)).map(mDoubler), 10, 110);
    assertCountSum(StreamSupport.stream(countTo(10)).map(mDoubler).map(mDoubler), 10, 220);

    exerciseOps(countTo(0), s -> s.map(LambdaTestHelpers.identity()), countTo(0));
    exerciseOps(countTo(1000), s -> s.map(LambdaTestHelpers.identity()), countTo(1000));
    // @@@ Force cast to integer so output is Stream<Integer> rather an IntStream
    //     this just ensures that no warnings are logged about boxing
    //     when the result is compared with the output
    exerciseOps(countTo(1000), s -> s.map(e -> (Integer) (1000 + e)), range(1001, 2000));
  }