Vec2 { public Vec2 set(double x, double y) { this.x = x; this.y = y; return this; } Vec2();  Vec2(double x, double y);  Vec2(Vec2 vector); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); float[] toArray(float[] result, int offset); double magnitude(); double magnitudeSquared(); double distanceTo(Vec2 vector); double distanceToSquared(Vec2 vector); Vec2 set(double x, double y); Vec2 set(Vec2 vector); Vec2 swap(Vec2 vector); Vec2 add(Vec2 vector); Vec2 subtract(Vec2 vector); Vec2 multiply(double scalar); Vec2 multiplyByMatrix(Matrix3 matrix); Vec2 divide(double divisor); Vec2 negate(); Vec2 normalize(); double dot(Vec2 vector); Vec2 mix(Vec2 vector, double weight); public double x; public double y; }
@Test public void testSet() throws Exception { Vec2 u = new Vec2(); Vec2 v = u.set(new Vec2(X, Y)); assertEquals("x", X, u.x, 0d); assertEquals("y", Y, u.y, 0d); assertEquals("v == u", u, v); }
@Test public void testSet_Doubles() throws Exception { Vec2 u = new Vec2(); Vec2 v = u.set(X, Y); assertEquals("x", X, u.x, 0d); assertEquals("y", Y, u.y, 0d); assertEquals("v == u", u, v); }
@Test(expected = IllegalArgumentException.class) public void testSet_WithNull() throws Exception { Vec2 u = new Vec2(); u.set(null); fail("Expected an IllegalArgumentException to be thrown."); }