From 99710e7db39ad1372975a27bc63b09c6b3dca272 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Mon, 6 Nov 2017 23:21:04 +0100 Subject: [PATCH] Tiny test for parsing date,time,tz --- .../test/BLETypeConversionsTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/BLETypeConversionsTest.java diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/BLETypeConversionsTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/BLETypeConversionsTest.java new file mode 100644 index 000000000..5360a6516 --- /dev/null +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/BLETypeConversionsTest.java @@ -0,0 +1,25 @@ +package nodomain.freeyourgadget.gadgetbridge.test; + +import org.junit.Test; + +import java.util.GregorianCalendar; + +import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; + +import static org.junit.Assert.assertTrue; + +public class BLETypeConversionsTest extends TestBase { + @Test + public void testTimeParsing() { + byte[] requested = new byte[] { + (byte) 0xe1, 0x07, 0x0a, 0x1d, 0x00, 0x1c, 0x00,0x08 + }; + byte[] received = new byte[] { + (byte) 0xe1, 0x07, 0x0a, 0x1c, 0x17, 0x1c, 0x00, 0x04 + }; + GregorianCalendar calRequested = BLETypeConversions.rawBytesToCalendar(requested, false); + GregorianCalendar calReceived = BLETypeConversions.rawBytesToCalendar(received, false); + + assertTrue(calRequested.getTime().equals(calReceived.getTime())); + } +}