@@ -0,0 +1,1643 @@
+/**%0A * Copyright (c) 2013 Simon Denier%0A */%0Apackage test.net.gecosi;%0A%0Aimport static org.hamcrest.CoreMatchers.equalTo;%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport net.gecosi.SiMessage;%0A%0Aimport org.junit.Test;%0A%0A/**%0A * @author Simon Denier%0A * @since Mar 15, 2013%0A *%0A */%0Apublic class SiMessageTest %7B%0A%0A%09private SiMessage message = new SiMessage(new byte%5B%5D %7B0x02, (byte) 0xF0, 0x01, 0x4D, 0x6D, 0x0A, 0x03%7D );%0A%09private SiMessage crc_fail = new SiMessage(new byte%5B%5D %7B0x02, (byte) 0xF0, 0x01, 0x4D, 0x00, 0x00, 0x03%7D );%0A%09private SiMessage bad_start = new SiMessage(new byte%5B%5D %7B0x00, (byte) 0xF0, 0x01, 0x4D, 0x00, 0x00, 0x03%7D );%0A%09private SiMessage bad_end = new SiMessage(new byte%5B%5D %7B0x02, (byte) 0xF0, 0x01, 0x4D, 0x00, 0x00, 0x00%7D );%0A%09private SiMessage bad_cmd = new SiMessage(new byte%5B%5D %7B0x02, (byte) 0x00, 0x01, 0x4D, 0x00, 0x00, 0x03%7D );%0A%0A%09@Test%0A%09public void commandByte() %7B%0A%09%09assertThat(new Byte(message.commandByte()), equalTo((byte) 0xF0));%0A%09%7D%0A%0A%09@Test%0A%09public void extractCRC() %7B%0A%09%09assertThat(message.extractCRC(), equalTo(0x6D0A));%0A%09%7D%0A%0A%09@Test%0A%09public void computeCRC() %7B%0A%09%09assertThat(message.computeCRC(), equalTo(0x6D0A));%0A%09%7D%0A%0A%09@Test%0A%09public void check() %7B%0A%09%09assertThat(message.check((byte) 0xF0), is(true));%0A%09%7D%0A%09%0A%09@Test%0A%09public void check_failsOnCrcError() %7B%0A%09%09assertThat(crc_fail.check((byte) 0xF0), is(false));%0A%09%7D%0A%0A%09@Test%0A%09public void check_failsOnBadStartOrBadEnd() %7B%0A%09%09assertThat(bad_start.check((byte) 0xF0), is(false));%0A%09%09assertThat(bad_end.check((byte) 0xF0), is(false));%0A%09%7D%0A%0A%09@Test%0A%09public void check_failsOnBadCommand() %7B%0A%09%09assertThat(bad_cmd.check((byte) 0xF0), is(false));%0A%09%7D%0A%0A%7D%0A

Test for SiMessage