Example #1
0
 @Test
 public void testMixed() {
   assertEquals((double) 10, RPNCalculator.calculate("10,8,+,3,-,2,*,3,/"), 0);
 }
Example #2
0
 @Test
 public void testPushed() {
   assertEquals((double) 2000, RPNCalculator.calculate("10,2,*,10,10,*,*"), 0);
 }
Example #3
0
 @Test
 public void testDevision() {
   assertEquals((double) 10, RPNCalculator.calculate("20,2,/"), 0);
   assertEquals((double) 5, RPNCalculator.calculate("20,2,/,2,/"), 0);
   assertEquals((double) 2.5, RPNCalculator.calculate("20,2,/,2,/,2,/"), 0);
 }
Example #4
0
 @Test
 public void testMultiplication() {
   assertEquals((double) 10, RPNCalculator.calculate("5,2,*"), 0);
   assertEquals((double) 20, RPNCalculator.calculate("5,2,*,2,*"), 0);
   assertEquals((double) 200, RPNCalculator.calculate("5,2,*,2,*,10,*"), 0);
 }
Example #5
0
 @Test
 public void testSubstraction() {
   assertEquals((double) 10, RPNCalculator.calculate("12,2,-"), 0);
   assertEquals((double) 10, RPNCalculator.calculate("16,4,-,2,-"), 0);
   assertEquals((double) 10, RPNCalculator.calculate("18,2,-,4,-,2,-"), 0);
 }
Example #6
0
 @Test
 public void testAddition() {
   assertEquals((double) 10, RPNCalculator.calculate("8,2,+"), 0);
   assertEquals((double) 10, RPNCalculator.calculate("4,4,+,2,+"), 0);
   assertEquals((double) 10, RPNCalculator.calculate("2,2,+,4,+,2,+"), 0);
 }
Example #7
0
 @Test
 public void testNoToCaclulate() {
   assertTrue((double) 10 == RPNCalculator.calculate("10"));
 }