@Test
public void testToArray() {

  final Vector3 vec1 = new Vector3();
  vec1.set(Math.PI, Double.MAX_VALUE, 42);
  final double[] array = vec1.toArray(null);
  final double[] array2 = vec1.toArray(new double[3]);
  assertNotNull(array);
  assertTrue(array.length == 3);
  assertTrue(array[0] == Math.PI);
  assertTrue(array[1] == Double.MAX_VALUE);
  assertTrue(array[2] == 42);
  assertNotNull(array2);
  assertTrue(array2.length == 3);
  assertTrue(array2[0] == Math.PI);
  assertTrue(array2[1] == Double.MAX_VALUE);
  assertTrue(array2[2] == 42);
  try {
    vec1.toArray(new double[1]);
    fail("toArray(d[1]) should have thrown ArrayIndexOutOfBoundsException.");
  } catch (final ArrayIndexOutOfBoundsException e) {}
  final float[] farray = vec1.toFloatArray(null);
  final float[] farray2 = vec1.toFloatArray(new float[3]);
  assertNotNull(farray);
  assertTrue(farray.length == 3);
  assertTrue(farray[0] == (float) Math.PI);
  assertTrue(farray[1] == (float) Double.MAX_VALUE);
  assertTrue(farray[2] == 42f);
  assertNotNull(farray2);
  assertTrue(farray2.length == 3);
  assertTrue(farray2[0] == (float) Math.PI);
  assertTrue(farray2[1] == (float) Double.MAX_VALUE);
  assertTrue(farray2[2] == 42f);
  try {
    vec1.toFloatArray(new float[1]);
    fail("toFloatArray(d[1]) should have thrown ArrayIndexOutOfBoundsException.");
  } catch (final ArrayIndexOutOfBoundsException e) {}
}