### Question:
Vector { public abstract float compareTo(Vector other); Vector(int n); final int size(); abstract float compareTo(Vector other); @Override String toString();  }### Answer:
@Test public void testCompareTo() throws Exception { Vector.VectorBuilder vectorBuilder = new Vector.VectorBuilder(ctor, 6); vectorBuilder.add(.0f); vectorBuilder.add(.2f); vectorBuilder.add(.4f); vectorBuilder.add(.6f); vectorBuilder.add(.8f); vectorBuilder.add(1.f); Vector one = vectorBuilder.build(); vectorBuilder = new Vector.VectorBuilder(ctor, 6); vectorBuilder .add(.0f) .add(.2f) .add(.4f) .add(.6f) .add(.8f) .add(1.f); Vector two = vectorBuilder.build(); double v = one.compareTo(two); Assert.assertEquals("These vectors are 100% likely to be the same.", 1.0, v, 0.0001); }
@Test public void testBig() throws Exception { int size = 200000000; Vector.VectorBuilder vb1 = new Vector.VectorBuilder(ctor, size); Vector.VectorBuilder vb2 = new Vector.VectorBuilder(ctor, size); for (int i = 0; i < size; i++) { vb1.add((float) i / (float) size); vb2.add((float) (i + 1) / (float) (size + 1)); } Vector v1 = vb1.build(); Vector v2 = vb2.build(); Assert.assertNotEquals("These vectors are not 100% likely to be the same.", 1.0, v1.compareTo(v2), 0.00001); }