コード例 #1
0
  @Test
  @Override
  public void subList() {
    // Not serializable

    MutableList<String> list = this.newWith("A", "B", "C", "D");
    MutableList<String> sublist = list.subList(1, 3);
    Verify.assertSize(2, sublist);
    Verify.assertContainsAll(sublist, "B", "C");
    sublist.add("X");
    Verify.assertSize(3, sublist);
    Verify.assertContainsAll(sublist, "B", "C", "X");
    Verify.assertSize(5, list);
    Verify.assertContainsAll(list, "A", "B", "C", "X", "D");
    sublist.remove("X");
    Verify.assertContainsAll(sublist, "B", "C");
    Verify.assertContainsAll(list, "A", "B", "C", "D");
    Assert.assertEquals("C", sublist.set(1, "R"));
    Verify.assertContainsAll(sublist, "B", "R");
    Verify.assertContainsAll(list, "A", "B", "R", "D");
    sublist.addAll(Arrays.asList("W", "G"));
    Verify.assertContainsAll(sublist, "B", "R", "W", "G");
    Verify.assertContainsAll(list, "A", "B", "R", "W", "G", "D");
    sublist.clear();
    Verify.assertEmpty(sublist);
    Assert.assertFalse(sublist.remove("X"));
    Verify.assertEmpty(sublist);
    Verify.assertContainsAll(list, "A", "D");
  }
コード例 #2
0
 @Override
 @Test
 public void clear() {
   super.clear();
   MutableList<String> list = new CompositeFastList<String>();
   list.addAll(FastList.newListWith("1", "2", "3", "4"));
   list.addAll(FastList.newListWith("3", "B", "3", "B"));
   list.clear();
   Assert.assertTrue(list.isEmpty());
   Assert.assertEquals(0, list.size());
 }
コード例 #3
0
 @Override
 @Test
 public void subList() {
   MutableList<String> list = this.newWith("A", "B", "C", "D");
   MutableList<String> sublist = list.subList(1, 3);
   Verify.assertPostSerializedEqualsAndHashCode(sublist);
   Verify.assertSize(2, sublist);
   Verify.assertContainsAll(sublist, "B", "C");
   sublist.add("X");
   Verify.assertSize(3, sublist);
   Verify.assertContainsAll(sublist, "B", "C", "X");
   Verify.assertSize(5, list);
   Verify.assertContainsAll(list, "A", "B", "C", "X", "D");
   sublist.remove("X");
   Verify.assertContainsAll(sublist, "B", "C");
   Verify.assertContainsAll(list, "A", "B", "C", "D");
   Assert.assertEquals("C", sublist.set(1, "R"));
   Verify.assertContainsAll(sublist, "B", "R");
   Verify.assertContainsAll(list, "A", "B", "R", "D");
   sublist.clear();
   Verify.assertEmpty(sublist);
   Verify.assertContainsAll(list, "A", "D");
 }