@@ -20,20 +20,12 @@ private static Stream<Arguments> provideValidExpressions() {
20
20
return Stream .of (Arguments .of ("3+2" , "+32" ), // Simple addition
21
21
Arguments .of ("1+(2+3)" , "+1+23" ), // Parentheses
22
22
Arguments .of ("(3+4)*5-6" , "-*+3456" ), // Nested operations
23
- Arguments .of ("a+b*c" , "+a*bc" ) // Multiplication precedence
24
- );
25
- }
26
-
27
- @ ParameterizedTest
28
- @ MethodSource ("provideInvalidExpressions" )
29
- void testInvalidExpressions (String infix , String expectedMessage ) {
30
- Exception exception = assertThrows (Exception .class , () -> InfixToPrefix .infix2Prefix (infix ));
31
- assertEquals (expectedMessage , exception .getMessage ());
32
- }
33
-
34
- private static Stream <Arguments > provideInvalidExpressions () {
35
- return Stream .of (Arguments .of ("((a+b)*c-d" , "invalid expression" ), // Missing closing bracket
36
- Arguments .of ("a++b" , "invalid expression" ) // Invalid operator
23
+ Arguments .of ("a+b*c" , "+a*bc" ), // Multiplication precedence
24
+ Arguments .of ("a+b*c/d" , "+a/b*c*d" ), // Division precedence
25
+ Arguments .of ("a+b*c-d" , "-+a*bc" ), // Subtraction precedence
26
+ Arguments .of ("a+b*c/d-e" , "-+a/b*cde" ), // Mixed precedence
27
+ Arguments .of ("a+b*(c-d)" , "+a-*bcd" ), // Parentheses precedence
28
+ Arguments .of ("a+b*(c-d)/e" , "/+a-*bcde" ), // Mixed precedence with parentheses
37
29
);
38
30
}
39
31
}
0 commit comments