diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/direct_bt/test_btaddress01.cpp | 24 | ||||
-rw-r--r-- | test/java/test/org/direct_bt/TestEUI48.java | 22 |
2 files changed, 46 insertions, 0 deletions
diff --git a/test/direct_bt/test_btaddress01.cpp b/test/direct_bt/test_btaddress01.cpp index afeeda9a..6cad6582 100644 --- a/test/direct_bt/test_btaddress01.cpp +++ b/test/direct_bt/test_btaddress01.cpp @@ -51,6 +51,21 @@ static void test_sub(const std::string& mac_str, const jau::darray<std::string>& (void) indices; } +static void test_sub(const std::string& mac_sub_str_exp, const std::string& mac_sub_str, const bool expected_result) { + std::string errmsg; + EUI48Sub mac_sub; + const bool res = EUI48Sub::scanEUI48Sub(mac_sub_str, mac_sub, errmsg); + if( res ) { + printf("EUI48Sub mac_sub: '%s' -> '%s'\n", mac_sub_str.c_str(), mac_sub.toString().c_str()); + if( expected_result ) { + REQUIRE(mac_sub_str_exp == mac_sub.toString()); + } + } else { + printf("EUI48Sub mac_sub: '%s' -> Error '%s'\n", mac_sub_str.c_str(), errmsg.c_str()); + } + REQUIRE( expected_result == res ); +} + TEST_CASE( "EUI48 Test 01", "[datatype][eui48]" ) { EUI48 mac01; INFO_STR("EUI48 size: whole0 "+std::to_string(sizeof(EUI48))); @@ -74,4 +89,13 @@ TEST_CASE( "EUI48 Test 01", "[datatype][eui48]" ) { const jau::darray<jau::snsize_t> mac03_sub_idxs = { 5, 4, 2, 2, 1, 1, 2, 0, 0, 0, 0, -1, 0}; test_sub(mac03_str, mac03_sub_strs, mac03_sub_idxs); } + { + const std::string mac_sub_str = "C0:10:22:A0:10:00"; + test_sub(mac_sub_str, mac_sub_str, true /* expected_result */); + } + { + const std::string mac_sub_str = "0600106"; + const std::string dummy; + test_sub(dummy, mac_sub_str, false /* expected_result */); + } } diff --git a/test/java/test/org/direct_bt/TestEUI48.java b/test/java/test/org/direct_bt/TestEUI48.java index e1dd54f0..93d3c40d 100644 --- a/test/java/test/org/direct_bt/TestEUI48.java +++ b/test/java/test/org/direct_bt/TestEUI48.java @@ -98,6 +98,20 @@ public class TestEUI48 extends JunitTracer { } } } + static void test_sub(final String mac_sub_str_exp, final String mac_sub_str, final boolean expected_result) { + final StringBuilder errmsg = new StringBuilder(); + final EUI48Sub mac_sub = new EUI48Sub (); + final boolean res = EUI48Sub.scanEUI48Sub(mac_sub_str, mac_sub, errmsg); + if( res ) { + System.out.printf("EUI48Sub mac_sub: '%s' -> '%s'\n", mac_sub_str, mac_sub.toString()); + if( expected_result ) { + Assert.assertEquals(mac_sub_str_exp, mac_sub.toString()); + } + } else { + System.out.printf("EUI48Sub mac_sub: '%s' -> Error '%s'\n", mac_sub_str, errmsg.toString()); + } + Assert.assertEquals(expected_result, res); + } @Test public void test01_EUI48AndSub() { @@ -116,6 +130,14 @@ public class TestEUI48 extends JunitTracer { final Integer[] mac03_sub_idxs = { 5, 4, 2, 2, 1, 1, 2, 0, 0, 0, 0, -1, 0}; test_sub(mac03_str, Arrays.asList(mac03_sub_strs), Arrays.asList(mac03_sub_idxs)); } + { + final String mac_sub_str = "C0:10:22:A0:10:00"; + test_sub(mac_sub_str, mac_sub_str, true /* expected_result */); + } + { + final String mac_sub_str = "0600106"; + test_sub(null, mac_sub_str, false /* expected_result */); + } } public static void main(final String args[]) throws IOException { |