示例#1
0
 @Test
 public void peekCommandProceed() throws DataFormatException {
   CommandRunner.proceed("push 12".split(" "), myStack);
   String inputData = "peek";
   String result = CommandRunner.proceed(inputData.split(" "), myStack);
   assertEquals("Peek - 12", result);
 }
示例#2
0
 @Test
 public void popCommandProceed() throws DataFormatException {
   CommandRunner.proceed("push 12".split(" "), myStack);
   String inputData = "pop";
   String result = CommandRunner.proceed(inputData.split(" "), myStack);
   assertEquals("Pop - 12", result);
   assertEquals(true, myStack.isEmpty());
 }
示例#3
0
  @Test
  public void isEmptyCommandProceed() throws DataFormatException {
    String inputData = "isEmpty";
    String result = CommandRunner.proceed(inputData.split(" "), myStack);
    assertEquals("Is empty - true", result);

    CommandRunner.proceed("push 12".split(" "), myStack);
    result = CommandRunner.proceed(inputData.split(" "), myStack);
    assertEquals("Is empty - false", result);
  }
示例#4
0
 @Test
 public void pushCommandProceed() throws DataFormatException {
   String inputData = "push 12";
   String result = CommandRunner.proceed(inputData.split(" "), myStack);
   assertEquals(Integer.valueOf(12), myStack.peek());
   assertEquals(true, result == null);
 }
示例#5
0
  @Test
  public void sizeCommandProceed() throws DataFormatException {
    String inputData = "size";
    String result = CommandRunner.proceed(inputData.split(" "), myStack);
    assertEquals("Size - 0", result);

    CommandRunner.proceed("push 12".split(" "), myStack);
    CommandRunner.proceed("push 10".split(" "), myStack);
    result = CommandRunner.proceed(inputData.split(" "), myStack);
    assertEquals("Size - 2", result);

    CommandRunner.proceed("pop".split(" "), myStack);
    result = CommandRunner.proceed(inputData.split(" "), myStack);
    assertEquals("Size - 1", result);
  }