package org.nusco.swimmers.creature.body.pns;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.nusco.swimmers.shared.physics.Vector;

public class WaveNerveTest {

	@Test
	public void generatesASinusWave() {
		final int length = 10;
		final double lengthAt45Degrees = 7.07;

		WaveNerve nerve = new WaveNerve(1.0 / 8);
		Vector signal = Vector.cartesian(0, length);

		assertApproxEqualsVector(Vector.ZERO, nerve.tick(signal));
		assertApproxEqualsVector(Vector.cartesian(-10, 0), nerve.tick(signal));
		assertApproxEqualsVector(Vector.ZERO, nerve.tick(signal));

		// on the negative side, the wave is twice as fast
		assertApproxEqualsVector(Vector.cartesian(lengthAt45Degrees, 0), nerve.tick(signal));
		assertApproxEqualsVector(Vector.cartesian(length, 0), nerve.tick(signal));
		assertApproxEqualsVector(Vector.cartesian(lengthAt45Degrees, 0), nerve.tick(signal));
	}

	private void assertApproxEqualsVector(Vector v1, Vector v2) {
		assertEquals(v1.toString(), v2.toString());
	}
}

@@ -498,18 +498,111 @@
 tesian(-
-10
+lengthAt45Degrees, 0), nerve.tick(signal));%0A%09%09assertApproxEqualsVector(Vector.cartesian(-length
 , 0), ne
@@ -646,36 +646,64 @@
 lsVector(Vector.
-ZERO
+cartesian(-lengthAt45Degrees, 0)
 , nerve.tick(sig
@@ -897,24 +897,35 @@
 esian(length
+At45Degrees
 , 0), nerve.
@@ -977,39 +977,12 @@
 tor.
-cartesian(lengthAt45Degrees, 0)
+ZERO
 , ne

Fix test