aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/helper
diff options
context:
space:
mode:
authorcasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
committercasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
commit7338b8730949ed027b3f8b31d7dca20687ebbb8b (patch)
treec2d171e6121818ab511460a786f69aab97a2a628 /src/test/java/org/traccar/helper
parentcdecd3fa4427a382c0b09f8ad9d69ec14388960a (diff)
parent85501f9cf4918d5eee345f83aed7a31eecb26b8d (diff)
downloadtrackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.gz
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.bz2
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.zip
Merge branch 'master' into develop
Diffstat (limited to 'src/test/java/org/traccar/helper')
-rw-r--r--src/test/java/org/traccar/helper/BufferUtilTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/java/org/traccar/helper/BufferUtilTest.java b/src/test/java/org/traccar/helper/BufferUtilTest.java
new file mode 100644
index 000000000..0196cef9d
--- /dev/null
+++ b/src/test/java/org/traccar/helper/BufferUtilTest.java
@@ -0,0 +1,41 @@
+package org.traccar.helper;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Test;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.Assert.assertEquals;
+
+public class BufferUtilTest {
+
+ @Test
+ public void testReadSignedMagnitudeInt() {
+ ByteBuf buf = Unpooled.wrappedBuffer(DataConverter.parseHex("80000001"));
+ assertEquals(-1, BufferUtil.readSignedMagnitudeInt(buf));
+ }
+
+ @Test
+ public void test1() {
+ ByteBuf buf = Unpooled.copiedBuffer("abcdef", StandardCharsets.US_ASCII);
+ assertEquals(2, BufferUtil.indexOf("cd", buf));
+ }
+
+ @Test
+ public void test2() {
+ ByteBuf buf = Unpooled.copiedBuffer("abcdef", StandardCharsets.US_ASCII);
+ buf.readerIndex(1);
+ buf.writerIndex(5);
+ assertEquals(2, BufferUtil.indexOf("cd", buf));
+ }
+
+ @Test
+ public void test3() {
+ ByteBuf buf = Unpooled.copiedBuffer("abcdefgh", StandardCharsets.US_ASCII);
+ buf.readerIndex(1);
+ buf.writerIndex(7);
+ assertEquals(3, BufferUtil.indexOf("de", buf, 2, 6));
+ }
+
+}