VariableHelper { static float[][] getFloatArray(int width, int height, float fillValue) { final float[][] floatArray = new float[width][height]; if (fillValue != 0.f) { for (int i = 0; i < width; i++) { final float[] vector = floatArray[i]; Arrays.fill(vector, fillValue); } } return floatArray; }    }
@Test public void testGetFilledArray_floats_filled() { final int width = 3; final int height = 4; final float[][] array = VariableHelper.getFloatArray(width, height, -776.2f); assertEquals(width, array.length); assertEquals(height, array[0].length); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { assertEquals(-776.2f, array[i][j], 1e-8); } } }
@Test public void testGetFilledArray_floats_unfilled() { final int width = 5; final int height = 2; final float[][] array = VariableHelper.getFloatArray(width, height, 0.f); assertEquals(width, array.length); assertEquals(height, array[0].length); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { assertEquals(0.f, array[i][j], 1e-8); } } }