diff options
Diffstat (limited to 'test/org/traccar/helper')
-rw-r--r-- | test/org/traccar/helper/ChannelBufferToolsTest.java | 13 | ||||
-rw-r--r-- | test/org/traccar/helper/ObdDecoderTest.java | 19 | ||||
-rw-r--r-- | test/org/traccar/helper/PatternBuilderTest.java | 2 |
3 files changed, 30 insertions, 4 deletions
diff --git a/test/org/traccar/helper/ChannelBufferToolsTest.java b/test/org/traccar/helper/ChannelBufferToolsTest.java index 6e2c6310c..6733a8f2a 100644 --- a/test/org/traccar/helper/ChannelBufferToolsTest.java +++ b/test/org/traccar/helper/ChannelBufferToolsTest.java @@ -1,8 +1,7 @@ package org.traccar.helper; import org.jboss.netty.buffer.ChannelBuffers; - -import static org.junit.Assert.*; +import org.junit.Assert; import org.junit.Test; public class ChannelBufferToolsTest { @@ -12,7 +11,15 @@ public class ChannelBufferToolsTest { byte[] buf = {0x01, (byte) 0x90, 0x34}; int result = ChannelBufferTools.readHexInteger( ChannelBuffers.wrappedBuffer(buf), 5); - assertEquals(1903, result); + Assert.assertEquals(1903, result); + } + + @Test + public void testReadCoordinate() { + byte[] buf = {0x03, (byte) 0x85, 0x22, 0x59, 0x34}; + double result = ChannelBufferTools.readCoordinate( + ChannelBuffers.wrappedBuffer(buf)); + Assert.assertEquals(38.870989, result, 0.00001); } } diff --git a/test/org/traccar/helper/ObdDecoderTest.java b/test/org/traccar/helper/ObdDecoderTest.java new file mode 100644 index 000000000..238f3e0a6 --- /dev/null +++ b/test/org/traccar/helper/ObdDecoderTest.java @@ -0,0 +1,19 @@ +package org.traccar.helper; + +import org.junit.Assert; +import org.junit.Test; + +public class ObdDecoderTest { + + @Test + public void testDecode() { + + Assert.assertEquals(83, ObdDecoder.decode(0x01, 0x05, "7b").getValue()); + Assert.assertEquals(1225, ObdDecoder.decode(0x01, 0x0C, "1324").getValue()); + Assert.assertEquals(20, ObdDecoder.decode(0x01, 0x0D, "14").getValue()); + Assert.assertEquals(64050, ObdDecoder.decode(0x01, 0x31, "fa32").getValue()); + Assert.assertEquals(25, ObdDecoder.decode(0x01, 0x2F, "41").getValue()); + + } + +} diff --git a/test/org/traccar/helper/PatternBuilderTest.java b/test/org/traccar/helper/PatternBuilderTest.java index 36054bcea..975cc1621 100644 --- a/test/org/traccar/helper/PatternBuilderTest.java +++ b/test/org/traccar/helper/PatternBuilderTest.java @@ -8,7 +8,7 @@ public class PatternBuilderTest { @Test public void testPatternBuilder() { Assert.assertEquals("\\$GPRMC", new PatternBuilder().text("$GPRMC").toString()); - Assert.assertEquals("(\\d{2}\\.\\p{XDigit}+)", new PatternBuilder().number("(dd.x+)").toString()); + Assert.assertEquals("(\\d{2}\\.[0-9a-fA-F]+)", new PatternBuilder().number("(dd.x+)").toString()); Assert.assertEquals("a(?:bc)?", new PatternBuilder().text("a").text("b").text("c").optional(2).toString()); Assert.assertEquals("a|b", new PatternBuilder().expression("a|b").toString()); Assert.assertEquals("ab\\|", new PatternBuilder().expression("ab|").toString()); |