コード例 #1
0
  @Test
  public void reverseForEachOnFromToInterval() {
    List<Integer> result = new ArrayList<>();
    Interval interval = Interval.oneTo(5);
    interval.reverseForEach(result::add);
    Verify.assertSize(5, result);
    Verify.assertContains(1, result);
    Verify.assertContains(5, result);
    Assert.assertEquals(Integer.valueOf(5), Iterate.getFirst(result));
    Assert.assertEquals(Integer.valueOf(1), Iterate.getLast(result));

    result.clear();
    interval.reverseThis().reverseForEach(result::add);
    Verify.assertSize(5, result);
    Verify.assertContains(1, result);
    Verify.assertContains(5, result);
    Assert.assertEquals(Integer.valueOf(1), Iterate.getFirst(result));
    Assert.assertEquals(Integer.valueOf(5), Iterate.getLast(result));
  }
コード例 #2
0
  @Test
  public void entrySet() {
    MutableSortedMap<Integer, String> map =
        this.newMapWithKeysValues(1, "One", 2, "2").asUnmodifiable();

    Verify.assertThrows(UnsupportedOperationException.class, () -> map.entrySet().remove(null));

    Verify.assertThrows(
        UnsupportedOperationException.class,
        () -> Iterate.getFirst(map.entrySet()).setValue("Three"));

    Assert.assertEquals(this.newMapWithKeysValues(1, "One", 2, "2"), map);
  }