Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. import static org.junit.Assert.*;
  2.  
  3. import org.junit.Test;
  4.  
  5. public class TestTauler
  6. {
  7.  
  8. private Tauler t = new Tauler(); // fer una altre clase per poder trure les variables i aixi no posarles 2 vegades
  9.  
  10.  
  11. @Test
  12. public void testTauler() {
  13.  
  14. boolean dins = false;
  15. t.accio();
  16.  
  17. for (int i = 0; i < 12; i++)
  18. {
  19. for (int j = 0; j < 12; j++)
  20. {
  21. if(t.matriuchar[i][j] == '-') {
  22. dins = true;//No hi ha bomba
  23. //En cas de fallas vol dir que tenim una bomba
  24.  
  25. }
  26. }
  27. }
  28.  
  29. assertTrue(dins);
  30. }
  31.  
  32. @Test
  33. public void testMatriuA0() {
  34.  
  35. boolean dins = false;
  36. t.accio();
  37.  
  38. for (int i = 0; i < 12; i++)
  39. {
  40. for (int j = 0; j < 12; j++)
  41. {
  42. if(t.matriuint[i][j] == 0) {
  43. dins = true;
  44.  
  45. }
  46. }
  47. }
  48.  
  49. assertTrue(dins);
  50. }
  51.  
  52.  
  53. @Test
  54. public void testObrirCasella() {
  55.  
  56. boolean dins = false;
  57. t.accio();
  58.  
  59. for (int i = 0; i < 12; i++)
  60. {
  61. for (int j = 0; j < 12; j++)
  62. {
  63. if(t.matriuint[i][j] == 9) {
  64. dins = true;//Hi ha blanc(buit)
  65. }
  66. }
  67. }
  68.  
  69. assertTrue(dins);
  70. }
  71.  
  72.  
  73. @Test
  74. public void testObrirCasellaFalse() {
  75.  
  76. boolean dins = false;
  77. t.accio();
  78.  
  79. for (int i = 0; i < 12; i++)
  80. {
  81. for (int j = 0; j < 12; j++)
  82. {
  83. if(t.matriuchar[i][j] != '/' || t.matriuint[i][j] != 9) {
  84. dins = true;//Hi ha blanc(buit)
  85. }
  86. }
  87. }
  88.  
  89. assertTrue(dins);
  90. }
  91.  
  92. @Test
  93. public void testGetFila() {
  94.  
  95. boolean dins = false;
  96. t.accio();
  97.  
  98. for (int i = 0; i < 12; i++)
  99. {
  100. for (int j = 0; j < 12; j++)
  101. {
  102. if(t.Fila == i) {
  103. dins = true;//Fila correcte
  104. }
  105. }
  106. }
  107.  
  108. assertTrue(dins);
  109. }
  110.  
  111. @Test
  112. public void testGetColumna() {
  113.  
  114. boolean dins = false;
  115. t.accio();
  116.  
  117. for (int i = 0; i < 12; i++)
  118. {
  119. for (int j = 0; j < 12; j++)
  120. {
  121. if(t.Columna == j) {
  122. dins = true;//Columne correcte
  123. }
  124. }
  125. }
  126.  
  127. assertTrue(dins);
  128. }
  129.  
  130. @Test
  131. public void testGetMatriuint() {
  132.  
  133. boolean dins = false;
  134. t.accio();
  135. int matriuintTest[][] = new int [12][12];
  136. for (int i = 0; i < 12; i++)
  137. {
  138. for (int j = 0; j < 12; j++)
  139. {
  140. if(t.matriuint[i][j] == matriuintTest[i][j]) {
  141. dins = true;//Matriu correcte
  142. }
  143. }
  144. }
  145.  
  146. assertTrue(dins);
  147. }
  148.  
  149. @Test
  150. public void testGetFinal() {
  151.  
  152. boolean dins = false;
  153. t.accio();
  154.  
  155. for (int i = 0; i < 12; i++)
  156. {
  157. for (int j = 0; j < 12; j++)
  158. {
  159. if(t.Fila == 0) {
  160. dins = true;//Matriu correcte
  161. }
  162. }
  163. }
  164.  
  165. assertTrue(dins);
  166. }
  167.  
  168. @Test
  169. public void testGetFinalFalse() {
  170.  
  171. boolean dins = false;
  172. t.accio();
  173.  
  174. for (int i = 0; i < 12; i++)
  175. {
  176. for (int j = 0; j < 12; j++)
  177. {
  178. if(t.Fila != 0) {
  179. dins = true;//Matriu correcte
  180. }
  181. }
  182. }
  183.  
  184. assertTrue(dins);
  185. }
  186.  
  187. @Test
  188. public void testAccionumero() { // test de particio equivalent
  189.  
  190. //Ficar desd un 1 a un 12 desde el teclat amira be
  191. boolean dins = false;
  192.  
  193. t.accio();
  194.  
  195. if (t.getFila() <= 12 && t.getFila() >= 1 && t.getColumna() <= 12 && t.getColumna() >= 1)
  196. {
  197. dins = true;
  198. }
  199. assertTrue(dins);
  200.  
  201.  
  202. }
  203.  
  204. @Test
  205. public void testOmplirCasella() //per fer el test primer caldrar fer la funcio obrirCasella()
  206. {
  207.  
  208. Tauler mt = new MockTaulerMines();
  209.  
  210. mt.matriuA0();
  211.  
  212. mt.omplirMines();
  213.  
  214. for (int i = 0; i < 12; i++)
  215. {
  216. for (int j = 0; j < 12; j++)
  217. {
  218. //falta fer mockobject de una secuencia de num introduits per teclat
  219. }
  220.  
  221. }
  222.  
  223.  
  224. }
  225.  
  226.  
  227.  
  228. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement