-added test for coureswind decoder -changed windID in raceVisionEncoder to byte as char is 2 bytes and can only transport 1 #story[778, 782]main
parent
c9a968a5fd
commit
f5000eea11
@ -0,0 +1,60 @@
|
|||||||
|
package seng302.Networking.MessageDecoders;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seng302.Networking.CourseWind;
|
||||||
|
import seng302.Networking.RaceVisionByteEncoder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by hba56 on 23/04/17.
|
||||||
|
*/
|
||||||
|
public class CourseWindDecoderTest {
|
||||||
|
@Test
|
||||||
|
public void getByteArrayTest(){
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
CourseWind testCourseWind1 = new CourseWind(1, time, 2,
|
||||||
|
3, 4, 5,
|
||||||
|
7, 6);
|
||||||
|
|
||||||
|
long time2 = System.currentTimeMillis();
|
||||||
|
CourseWind testCourseWind2 = new CourseWind(2, time2, 2,
|
||||||
|
3, 4, 5,
|
||||||
|
7, 6);
|
||||||
|
|
||||||
|
ArrayList<CourseWind> testCourseWinds = new ArrayList<CourseWind>();
|
||||||
|
testCourseWinds.add(testCourseWind1);
|
||||||
|
testCourseWinds.add(testCourseWind2);
|
||||||
|
|
||||||
|
|
||||||
|
RaceVisionByteEncoder raceVisionByteEncoder = new RaceVisionByteEncoder();
|
||||||
|
|
||||||
|
byte[] testEncodedCourseWind = raceVisionByteEncoder.courseWind((byte) 1, testCourseWinds);
|
||||||
|
|
||||||
|
CourseWindDecoder testDecoder = new CourseWindDecoder(testEncodedCourseWind);
|
||||||
|
|
||||||
|
ArrayList<CourseWind> testDecodedCourseWinds = testDecoder.getLoopMessages();
|
||||||
|
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getID(), testDecodedCourseWinds.get(0).getID());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getTime(), testDecodedCourseWinds.get(0).getTime());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getRaceID(), testDecodedCourseWinds.get(0).getRaceID());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getWindDirection(), testDecodedCourseWinds.get(0).getWindDirection());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getWindSpeed(), testDecodedCourseWinds.get(0).getWindSpeed());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getBestUpwindAngle(), testDecodedCourseWinds.get(0).getBestUpwindAngle());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getBestDownwindAngle(), testDecodedCourseWinds.get(0).getBestDownwindAngle());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(0).getFlags(), testDecodedCourseWinds.get(0).getFlags());
|
||||||
|
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getID(), testDecodedCourseWinds.get(1).getID());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getTime(), testDecodedCourseWinds.get(1).getTime());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getRaceID(), testDecodedCourseWinds.get(1).getRaceID());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getWindDirection(), testDecodedCourseWinds.get(1).getWindDirection());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getWindSpeed(), testDecodedCourseWinds.get(1).getWindSpeed());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getBestUpwindAngle(), testDecodedCourseWinds.get(1).getBestUpwindAngle());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getBestDownwindAngle(), testDecodedCourseWinds.get(1).getBestDownwindAngle());
|
||||||
|
Assert.assertEquals(testCourseWinds.get(1).getFlags(), testDecodedCourseWinds.get(1).getFlags());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue