Advertisement
VladNitu

miritestehardnp1

Feb 27th, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. package weblab;
  2.  
  3. import game.*;
  4. import org.junit.*;
  5. import org.junit.rules.*;
  6.  
  7. import static org.junit.Assert.assertEquals;
  8.  
  9. public class UTest {
  10. // TIP: If WebLab kills your process after a minute, you can
  11. // try to reduce the number of tests being run by commenting
  12. // them out.
  13.  
  14. private static final String LEVEL_SET = "Aymeric_Hard.sok";
  15. private static final boolean REQUIRE_OPT = false;
  16. private static final int SOLVER_TIMEOUT = 4000;
  17.  
  18. private static IAgent getAgent() {
  19. return new Solution();
  20. }
  21.  
  22. private static void testLevel(IAgent agent, int level) {
  23. boolean verbose = false;
  24. String agentId = null;
  25.  
  26. agent.init(REQUIRE_OPT, verbose);
  27.  
  28.  
  29. SokobanResult result =
  30. Sokoban.simAgentLevel(agentId, LEVEL_SET, level, SOLVER_TIMEOUT, agent, verbose, REQUIRE_OPT);
  31.  
  32. SokobanResultType resultType = result.getResult();
  33. assertEquals(SokobanResultType.VICTORY, resultType);
  34. }
  35.  
  36. private long time = 0;
  37.  
  38. @Rule
  39. public TestName name = new TestName();
  40.  
  41. @Before
  42. public void setUp() {
  43. time = System.currentTimeMillis();
  44. }
  45.  
  46. @After
  47. public void tearDown() {
  48. System.out.println("Test '" + name.getMethodName() + "' took " + (System.currentTimeMillis() - time) + "ms");
  49. }
  50.  
  51. @Test(timeout = 4100)
  52. public void level1() {
  53. testLevel(getAgent(), 1);
  54. }
  55.  
  56. @Test(timeout = 4100)
  57. public void level2() {
  58. testLevel(getAgent(), 2);
  59. }
  60.  
  61. @Test(timeout = 4100)
  62. public void level3() {
  63. testLevel(getAgent(), 3);
  64. }
  65.  
  66. @Test(timeout = 4100)
  67. public void level4() {
  68. testLevel(getAgent(), 4);
  69. }
  70.  
  71. @Test(timeout = 4100)
  72. public void level5() {
  73. testLevel(getAgent(), 5);
  74. }
  75.  
  76. @Test(timeout = 4100)
  77. public void level6() {
  78. testLevel(getAgent(), 6);
  79. }
  80.  
  81. @Test(timeout = 4100)
  82. public void level7() {
  83. testLevel(getAgent(), 7);
  84. }
  85.  
  86. @Test(timeout = 4100)
  87. public void level8() {
  88. testLevel(getAgent(), 8);
  89. }
  90.  
  91. @Test(timeout = 4100)
  92. public void level9() {
  93. testLevel(getAgent(), 9);
  94. }
  95.  
  96. @Test(timeout = 4100)
  97. public void level10() {
  98. testLevel(getAgent(), 10);
  99. }
  100.  
  101. @Test(timeout = 4100)
  102. public void level11() {
  103. testLevel(getAgent(), 11);
  104. }
  105.  
  106. @Test(timeout = 4100)
  107. public void level12() {
  108. testLevel(getAgent(), 12);
  109. }
  110.  
  111. @Test(timeout = 4100)
  112. public void level13() {
  113. testLevel(getAgent(), 13);
  114. }
  115.  
  116. @Test(timeout = 4100)
  117. public void level14() {
  118. testLevel(getAgent(), 14);
  119. }
  120.  
  121. @Test(timeout = 4100)
  122. public void level15() {
  123. testLevel(getAgent(), 15);
  124. }
  125.  
  126. @Test(timeout = 4100)
  127. public void level16() {
  128. testLevel(getAgent(), 16);
  129. }
  130.  
  131. @Test(timeout = 4100)
  132. public void level17() {
  133. testLevel(getAgent(), 17);
  134. }
  135.  
  136. @Test(timeout = 4100)
  137. public void level18() {
  138. testLevel(getAgent(), 18);
  139. }
  140.  
  141. @Test(timeout = 4100)
  142. public void level19() {
  143. testLevel(getAgent(), 19);
  144. }
  145.  
  146. @Test(timeout = 4100)
  147. public void level20() {
  148. testLevel(getAgent(), 20);
  149. }
  150.  
  151.  
  152. }
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement