GameOfLife { protected static byte[] longToBytes(long initialState) { byte[] b = new byte[8]; for(int i = 0; i < 8; i++) { b[7 - i] = (byte) (initialState >>> (i * 8)); } return b; } GameOfLife(int width, byte[] initialStateInBytes, int maxX, int maxY, int maxIterations); static void emptyMatrix(byte[][] matrix, int maxX, int maxY); static void printMatrix(byte[][] matrix, int maxX, int maxY, PrintStream stream); void nextCycle(); static void main(String[] args);  }
@Test public void testLongToBytes() { byte[] bytes1 = new byte[] { 0, 0, 1, 8, 0, 0, 7, 16 }; long val = GameOfLife.bytesToLong(bytes1); byte[] bytes2 = GameOfLife.longToBytes(val); assertEquals(bytes2[0], 0); assertEquals(bytes2[1], 0); assertEquals(bytes2[2], 1); assertEquals(bytes2[3], 8); assertEquals(bytes2[4], 0); assertEquals(bytes2[5], 0); assertEquals(bytes2[6], 7); assertEquals(bytes2[7], 16); }