예제 #1
0
 @Test
 public void testParseInputToCommand13() {
   List<Double> list = new ArrayList<Double>();
   list.add(1.0);
   list.add(2.0);
   String vaildInput = "add 1 !0 2 3";
   History.addToHistory(new AddCmd(list).calculate());
   Command output = Parser.parseInputToCommand(vaildInput);
   assertEquals(AddCmd.class, output.getClass());
 }
예제 #2
0
 @Test
 public void testparseInputToCommand11() {
   History.clearHistory();
   String validInput = "add 1 !1";
   /*
    * we expect there to be an error because the history logging is done by
    * the driver and therefore the parser will have no way of knowing if a
    * historic value was computed on its own
    */
   try {
     Command output = Parser.parseInputToCommand(validInput);
     fail();
   } catch (IllegalArgumentException e) {
     assertEquals("The index 1 has no associated history", e.getMessage());
   }
 }
예제 #3
0
 @Test(expected = IllegalArgumentException.class)
 public void testparseInputToCommand6() throws Exception {
   String invalidInput = "add ";
   Parser.parseInputToCommand(invalidInput);
   fail();
 }
예제 #4
0
 @Test
 public void testparseInputToSubCommand() {
   String validInput = "sub 1 2 3";
   Command cmd = Parser.parseInputToCommand(validInput);
   assertEquals(SubCmd.class, cmd.getClass());
 }
예제 #5
0
 @Test
 public void testparseInputToHistCommand() {
   String validInput = "hist";
   Command cmd = Parser.parseInputToCommand(validInput);
   assertEquals(HistCmd.class, cmd.getClass());
 }
예제 #6
0
 @Test
 public void testparseInputToAddSquaresCommand() {
   String validInput = "addsquares 1 2 3";
   Command cmd = Parser.parseInputToCommand(validInput);
   assertEquals(AddSquaresCmd.class, cmd.getClass());
 }
예제 #7
0
 @Test(expected = IllegalArgumentException.class)
 public void testParseInputCommand14() {
   String invalidInput = "!2 1 2 3";
   Parser.parseInputToCommand(invalidInput);
   fail();
 }
예제 #8
0
 @Test
 public void testparseInputToCommand10() {
   String validInput = "div 1 2 3";
   Command output = Parser.parseInputToCommand(validInput);
   assertEquals(DivCmd.class, output.getClass());
 }
예제 #9
0
 @Test
 public void testparseInputToCommand9() {
   String validInput = "mul 1 2 3 4";
   Command output = Parser.parseInputToCommand(validInput);
   assertEquals(MulCmd.class, output.getClass());
 }