Esempio n. 1
0
 @Test
 public void testIsFull() throws Exception {
   for (String inputArrayItem : inputArray) {
     assertFalse(stack.isFull());
     stack.push(inputArray[0]);
   }
   assertTrue(stack.isFull());
 }
Esempio n. 2
0
 @Test
 public void testGetSize() throws Exception {
   assertEquals(0, stack.getSize());
   for (int i = 0; i < inputArray.length; i++) {
     stack.push(inputArray[i]);
     assertEquals(i + 1, stack.getSize());
   }
 }
Esempio n. 3
0
 @Test
 public void testPopAll() throws Exception {
   for (String inputArrayItem : inputArray) {
     stack.push(inputArrayItem);
   }
   stack.popAll(inputList);
   assertEquals(inputArray.length, inputList.size());
   assertTrue(stack.isEmpty());
   Arrays.sort(inputArray, new LengthComparator());
   inputList.sort(new LengthComparator());
   assertEquals(Arrays.deepToString(inputArray), inputList.toString());
 }
Esempio n. 4
0
 @Test
 public void testPop() throws Exception {
   stack.push(inputArray[0]);
   assertEquals(inputArray[0], stack.pop());
   stack.push(inputArray[0]);
   stack.push(inputArray[1]);
   stack.push(inputArray[2]);
   stack.pop();
   assertEquals(inputArray[1], stack.pop());
 }
Esempio n. 5
0
 @Test
 public void testPushAll() throws Exception {
   for (String inputItem : inputArray) {
     inputList.add(inputItem);
   }
   stack.pushAll(inputList);
   assertEquals(inputArray.length, stack.getSize());
   assertTrue(stack.isFull());
   for (int i = inputArray.length - 1; i >= 0; i--) {
     assertEquals(inputArray[i], stack.pop());
   }
   assertEquals(0, stack.getSize());
   assertTrue(stack.isEmpty());
 }
Esempio n. 6
0
 @Test
 public void testIsEmpty() throws Exception {
   assertTrue(stack.isEmpty());
   stack.push(inputArray[0]);
   assertFalse(stack.isEmpty());
 }