Skip to content

Commit

Permalink
shared-tests #14
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosKozak committed Sep 4, 2023
1 parent 22c1f8f commit 593af85
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 170 deletions.
2 changes: 2 additions & 0 deletions pump/rileylink/build.gradle
Expand Up @@ -20,4 +20,6 @@ dependencies {
implementation project(':core:ui')
implementation project(':pump:pump-common')
implementation project(':pump:pump-core')

testImplementation project(':app-wear-shared:shared-tests')
}

This file was deleted.

@@ -1,98 +1,98 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble

import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion
import org.junit.Assert
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test

class RFSpyTest : TestBase() {
@Suppress("SpellCheckingInspection") class RFSpyTest : TestBase() {

@Test fun testGetFirmwareVersion() {
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_1_0,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_1_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_1_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_0,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_0,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_2,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_2,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_2,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_2_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_3_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_3_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_3_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_3_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_4_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_4_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_4_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.Version_4_x,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.UnknownVersion,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.UnknownVersion,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0")
)
Assert.assertEquals(
Assertions.assertEquals(
RileyLinkFirmwareVersion.UnknownVersion,
RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5")
)
Expand Down
Expand Up @@ -3,7 +3,6 @@
import android.util.Log;

import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

Expand All @@ -25,43 +24,45 @@ public class RFToolsParametrizedUTest {
@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays
.asList(new Object[][] { //
{ ByteUtil.createByteArrayFromCompactString("00"), ByteUtil.createByteArrayFromCompactString("5555") },
//
{
ByteUtil.createByteArrayFromCompactString("0000"),
ByteUtil.createByteArrayFromCompactString("555555") }, //
{
ByteUtil.createByteArrayFromCompactString("A71289865D00BE"),
ByteUtil.createByteArrayFromCompactString("A96C726996A694D5552CE5") }, //
{
ByteUtil.createByteArrayFromCompactString("A7128986060015"),
ByteUtil.createByteArrayFromCompactString("A96C726996A6566555C655") }, //
{
ByteUtil.createByteArrayFromCompactString("A7128986150956"),
ByteUtil.createByteArrayFromCompactString("A96C726996A6C655599665") }, //
{
ByteUtil.createByteArrayFromCompactString("A71289868D00B0"),
ByteUtil.createByteArrayFromCompactString("A96C726996A668D5552D55") }, //
{
ByteUtil
.createByteArrayFromCompactString("A71289868D090337323200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039"),
ByteUtil
.createByteArrayFromCompactString("A96C726996A668D5595638D68F28F25555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555558D95")
//
}, //
});
.asList(new Object[][]{ //
{ByteUtil.createByteArrayFromCompactString("00"), ByteUtil.createByteArrayFromCompactString("5555")},
//
{
ByteUtil.createByteArrayFromCompactString("0000"),
ByteUtil.createByteArrayFromCompactString("555555")}, //
{
ByteUtil.createByteArrayFromCompactString("A71289865D00BE"),
ByteUtil.createByteArrayFromCompactString("A96C726996A694D5552CE5")}, //
{
ByteUtil.createByteArrayFromCompactString("A7128986060015"),
ByteUtil.createByteArrayFromCompactString("A96C726996A6566555C655")}, //
{
ByteUtil.createByteArrayFromCompactString("A7128986150956"),
ByteUtil.createByteArrayFromCompactString("A96C726996A6C655599665")}, //
{
ByteUtil.createByteArrayFromCompactString("A71289868D00B0"),
ByteUtil.createByteArrayFromCompactString("A96C726996A668D5552D55")}, //
{
ByteUtil
.createByteArrayFromCompactString("A71289868D090337323200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039"),
ByteUtil
.createByteArrayFromCompactString("A96C726996A668D5595638D68F28F25555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555558D95")
//
}, //
});
}

@Parameterized.Parameter
// first data value (0) is default
public/* NOT private */byte[] decoded;
public/* NOT private */ byte[] decoded;

@Parameterized.Parameter(1)
public/* NOT private */byte[] encoded;
public/* NOT private */ byte[] encoded;


// @Test
/**
* @noinspection JUnit3StyleTestMethodInJUnit4Class, unused
*/ // @Test
public void testEncodeGeoff() {

Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
Expand All @@ -88,39 +89,40 @@ public void testEncodeGeoff() {
// LOG.error("test: compare failed.");
// }
// testCompose(new byte[] {(byte)0xa7, (byte)0xa7});
byte[] bs = decoder.encode4b6b(new byte[] { (byte)0xa7 });
byte[] out = new byte[] { (byte)(0xa9), 0x65 };
byte[] bs = decoder.encode4b6b(new byte[]{(byte) 0xa7});
byte[] out = new byte[]{(byte) (0xa9), 0x65};
if (ByteUtil.compare(bs, out) != 0) {
Log.e(
TAG,
"encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ ByteUtil.shortHexString(bs));
TAG,
"encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ ByteUtil.shortHexString(bs));
Assert.fail();
}
bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12 });
out = new byte[] { (byte)(0xa9), 0x6c, 0x72 };
bs = decoder.encode4b6b(new byte[]{(byte) 0xa7, 0x12});
out = new byte[]{(byte) (0xa9), 0x6c, 0x72};
if (ByteUtil.compare(bs, out) != 0) {
Log.e(
TAG,
"encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ ByteUtil.shortHexString(bs));
TAG,
"encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ ByteUtil.shortHexString(bs));
Assert.fail();
}
bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12, (byte)0xa7 });
out = new byte[] { (byte)(0xa9), 0x6c, 0x72, (byte)0xa9, 0x65 };
bs = decoder.encode4b6b(new byte[]{(byte) 0xa7, 0x12, (byte) 0xa7});
out = new byte[]{(byte) (0xa9), 0x6c, 0x72, (byte) 0xa9, 0x65};
if (ByteUtil.compare(bs, out) != 0) {
Log.e(
TAG,
"encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ ByteUtil.shortHexString(bs));
TAG,
"encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got "
+ ByteUtil.shortHexString(bs));
Assert.fail();
}

}



// @Test
/**
* @noinspection JUnit3StyleTestMethodInJUnit4Class, unused
*/ // @Test
public void testParametrizedGeoffEncode() {

Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
Expand All @@ -135,7 +137,9 @@ public void testParametrizedGeoffEncode() {
}


// @Test
/**
* @noinspection unused
*/ // @Test
public void geoffDecode() throws Exception {
Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);

Expand All @@ -145,7 +149,9 @@ public void geoffDecode() throws Exception {
}


// @Test
/**
* @noinspection unused
*/ // @Test
public void geoffEncode() {

Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null);
Expand Down

0 comments on commit 593af85

Please sign in to comment.