@Test
  public void count() {
    ImmutableMap<String, String> map =
        this.newMapWithKeysValues("1", "One", "2", "Two", "3", "Three", "4", "Four");

    int actual = map.count(Predicates.or("One"::equals, "Three"::equals));

    switch (map.size()) {
      case 1:
        Assert.assertEquals(1, actual);
        break;
      case 2:
        Assert.assertEquals(1, actual);
        break;
      case 3:
        Assert.assertEquals(2, actual);
        break;
      case 4:
        Assert.assertEquals(2, actual);
        break;
      default:
        Assert.assertEquals(0, actual);
        break;
    }
  }
コード例 #2
0
  @Test
  public void count() {
    MutableMap<String, String> map = this.classUnderTest();

    int actual = map.count(Predicates.or("One"::equals, "Three"::equals));

    switch (map.size()) {
      case 1:
        Assert.assertEquals(1, actual);
        break;
      case 2:
        Assert.assertEquals(1, actual);
        break;
      case 3:
        Assert.assertEquals(2, actual);
        break;
      default:
        Assert.assertEquals(0, actual);
        break;
    }
  }