Пример #1
0
 /** Moo */
 @Test
 public void trimToSize() {
   words.trimToSize();
   assertEquals(0, words.size());
   words.add("1");
   words.trimToSize();
   assertEquals(1, words.size());
 }
Пример #2
0
 /** Moo */
 @Test
 public void testRemove() {
   words.add("5");
   words.add("6");
   words.add("7");
   assertEquals("5", words.remove(0));
   assertEquals(2, words.size());
   assertEquals("7", words.remove(1));
   assertEquals(1, words.size());
 }
Пример #3
0
  /** Moo */
  @Test
  public void testAdd() {
    assertTrue(words.add("hello"));
    assertEquals(1, words.size());
    assertTrue(words.add("world"));
    assertEquals(2, words.size());
    assertTrue(words.add("blue"));
    assertEquals(3, words.size());

    assertSame("hello", words.get(0));
    assertSame("world", words.get(1));
    assertSame("blue", words.get(2));
  }
Пример #4
0
 /** Moo */
 @Test(expected = IndexOutOfBoundsException.class)
 public void testSetIndexOutOfBoundsException2() {
   assertEquals(0, words.size());
   words.add("6");
   words.add("7");
   words.set(2, "5");
 }
Пример #5
0
 /** Moo */
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetFail3() {
   assertEquals(0, words.size());
   words.add("0");
   words.add("0");
   words.add("0");
   words.get(3);
 }
Пример #6
0
 /** Moo */
 @Test
 public void testLargeAdd() {
   for (int i = 0; i < 10000; i++) {
     words.add("" + i);
   }
   assertEquals(10000, words.size());
   assertEquals("0", words.get(0));
   assertEquals("9999", words.get(9999));
 }
Пример #7
0
 /** Moo */
 @Test
 public void testRemoveObject() {
   words.add("5");
   words.add("6");
   words.add("7");
   assertTrue(words.remove("6"));
   assertFalse(words.remove("8"));
   assertEquals(2, words.size());
 }
Пример #8
0
  /** Moo */
  @Test
  public void testSet() {

    words.add("6");
    words.add("7");
    assertEquals("6", words.set(0, "3"));
    assertEquals("3", words.get(0));
    assertEquals("7", words.get(1));
    assertEquals(2, words.size());
  }
Пример #9
0
 /** Moo */
 @Test
 public void testAddLoc() {
   words.add(0, "5");
   System.out.println(words.toString());
   words.add(0, "3");
   System.out.println(words.toString());
   words.add(1, "4");
   System.out.println(words.toString());
   assertSame("3", words.get(0));
   assertSame("4", words.get(1));
   assertSame("5", words.get(2));
   assertEquals(3, words.size());
 }
Пример #10
0
 @Override
 public boolean hasNext() {
   return current < keys.size();
 }
Пример #11
0
 /** Moo */
 @Test(expected = IndexOutOfBoundsException.class)
 public void testAddIndexOutOfBoundsException3() {
   System.out.println(words.size());
   assertEquals(0, words.size());
   words.add(2, "5");
 }
Пример #12
0
 /** Moo */
 @Test(expected = IndexOutOfBoundsException.class)
 public void testAddIndexOutOfBoundsException2() {
   assertEquals(0, words.size());
   words.add(-1, "5");
 }
Пример #13
0
 /** Moo */
 @Test
 public void testConstructor() {
   words = new MyArrayList();
   assertEquals(0, words.size());
 }
Пример #14
0
 /** Moo */
 @Test(expected = IndexOutOfBoundsException.class)
 public void testRemoveIndexOutOfBoundsException2() {
   assertEquals(0, words.size());
   words.add("0");
   words.remove(1);
 }
Пример #15
0
 public static void quickSortClassic(MyArrayList a, IPivotStrategy pivotStrategy) {
   quickSortClassic(a, 0, a.size() - 1, pivotStrategy);
 }
Пример #16
0
 /** Moo */
 @Test(expected = IllegalArgumentException.class)
 public void testConstructor2() {
   words = new MyArrayList(-1);
   assertEquals(0, words.size());
 }
Пример #17
0
 public static int binarySearch(MyArrayList list, Object key) {
   if (list.isEmpty()) return -1;
   return binarySearch(list, 0, list.size() - 1, key);
 }
Пример #18
0
 /** Moo */
 @Test
 public void testClear() {
   words.add("5");
   words.clear();
   assertEquals(0, words.size());
 }