import java.util.Arrays; import java.util.stream.Collectors; import org.junit.Test; import org.junit.Assert; public class SimpleTest { InfixToPostfix fixer = new StackInfixToPostfix(); private String infixToPostfix(String infix) { return fixer.infixToPostfix(Arrays.asList(infix.split(" "))) .stream().collect(Collectors.joining(" ")); } @Test public void testConstant() { Assert.assertEquals("123", infixToPostfix("123")); } @Test public void testAddition() { Assert.assertEquals("1 2 +", infixToPostfix("1 + 2")); } @Test public void testSubstraction() { Assert.assertEquals("1 2 -", infixToPostfix("1 - 2")); } @Test public void testMultiplication() { Assert.assertEquals("1 2 *", infixToPostfix("1 * 2")); } @Test public void testDivision() { Assert.assertEquals("1 2 /", infixToPostfix("1 / 2")); } @Test public void testParenthesisLeft() { Assert.assertEquals("1 2 3 + *", infixToPostfix("1 * ( 2 + 3 )")); } @Test public void testParenthesisRight() { Assert.assertEquals("1 2 + 3 *", infixToPostfix("( 1 + 2 ) * 3")); } }