Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. import org.junit.Test;
  2.  
  3. import static org.junit.Assert.*;
  4.  
  5. public class SolutionTest {
  6. @Test
  7. public void sampleTests() throws Exception {
  8. System.out.println("\n******** SampleTests ********");
  9. assertEquals(76, Solution.solution("13+62*7+*"));
  10. assertEquals(9, Solution.solution("99*9"));
  11. assertEquals(730, Solution.solution("99*9*1+"));
  12. }
  13.  
  14. @Test
  15. public void wrongArgumentsTests() throws Exception {
  16. System.out.println("\n******** WrongArgumentsTests ********");
  17. assertEquals(-1, Solution.solution("13+62*7-*"));
  18. assertEquals(-1, Solution.solution("abc1234+"));
  19. assertEquals(-1, Solution.solution("2+2=4"));
  20. assertEquals(-1, Solution.solution(""));
  21. }
  22.  
  23. @Test
  24. public void emptyStackTests() throws Exception {
  25. System.out.println("\n******** EmptyStackTests ********");
  26. assertEquals(76, Solution.solution("13+62*7+*+"));
  27. assertEquals(11, Solution.solution("+56+"));
  28. assertEquals(-1, Solution.solution("+*+*+*++"));
  29. assertEquals(6, Solution.solution("+*5+6*"));
  30. }
  31.  
  32. @Test
  33. public void overflowIntegerTest() throws Exception {
  34. System.out.println("\n******** OverflowIntegerTest ********");
  35. StringBuilder sb = new StringBuilder();
  36. sb.append("99*");
  37. for(int i = 0; i < 1500; i++)
  38. sb.append("9*");
  39. assertEquals(9, Solution.solution(sb.toString()));
  40. }
  41.  
  42. @Test
  43. public void longStringTest() throws Exception {
  44. System.out.println("\n******** LongStringTest ********");
  45. StringBuilder sb = new StringBuilder();
  46. for(int i = 0; i < 33333; i++)
  47. sb.append("55*44+");
  48. sb.append("2+");
  49. String S = sb.toString();
  50. System.out.println("Length of string: " + S.length());
  51. assertEquals(10, Solution.solution(S));
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement