@Test
public void testToArray() {

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