mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user