Added Boat location messages to the mock streaming data interface

- Added static methods to convert between binary packed lat/longs and floating point numbers

Tags: #story[829]
This commit is contained in:
Michael Rausch
2017-04-26 22:38:39 +12:00
parent 1f8f1f0f86
commit bc31987f96
6 changed files with 214 additions and 1 deletions
@@ -0,0 +1,35 @@
package seng302.server;
import org.junit.Test;
import seng302.server.messages.BoatLocationMessage;
import static junit.framework.TestCase.assertEquals;
/**
* Test conversions used by the boat location messages
*/
public class TestConversions {
@Test
public void testLatLonConversion(){
long binaryPacked = BoatLocationMessage.latLonToBinaryPackedLong(3232.323);
double original = BoatLocationMessage.binaryPackedToLatLon(binaryPacked);
assertEquals(3232.323, original, 0.01);
}
@Test
public void testWindAngleConversion(){
long binaryPacked = BoatLocationMessage.windAngleToBinaryPackedLong(3232.323);
double original = BoatLocationMessage.binaryPackedWindAngleToDouble(binaryPacked);
assertEquals(3232.323, original, 0.01);
}
@Test
public void testHeadingConversion(){
long binaryPacked = BoatLocationMessage.headingToBinaryPackedLong(3232.323);
double original = BoatLocationMessage.binaryPackedHeadingToDouble(binaryPacked);
assertEquals(3232.323, original, 0.01);
}
}