Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public void test_copy() {
  2.         // for copy to work, the contents of the board need to be the same
  3.         // but the actual references cannot be the same (i.e. we created a new
  4.         // board in memory)
  5.         SnakeBoard boardCopy = BOARD_START.copy();
  6.         assertNotSame(BOARD_START, boardCopy);
  7.         char[][] copyGrid = boardCopy.getGrid();
  8.         char[][] origGrid = BOARD_START.getGrid();
  9.         assertNotSame(origGrid, copyGrid);
  10.         for (int row = 0; row < copyGrid.length; row++) {
  11.             assertNotSame(origGrid[row], copyGrid[row]);
  12.             for (int col = 0; col < copyGrid[row].length; col++) {
  13.                 assertEquals(origGrid[row][col], copyGrid[row][col]);
  14.             }
  15.         }
  16.     }
  17.  public static void main(String[] args) {
  18.         System.out.println(BASIC.toString());
  19.         System.out.println(BASIC_2.toString());
  20.         System.out.println(BASIC_3.toString());
  21.         System.out.println(BASIC_4.toString());
  22.         System.out.println(BASIC_5.toString());
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement