14 const EUI48 mac(mac_str);
15 printf(
"Test EUI48 mac: '%s' -> '%s'\n", mac_str.c_str(), mac.
toString().c_str());
22 jau::for_each_const(mac_sub_strs, [&byte_order, &i, &mac, &indices](
const std::string &mac_sub_str)
noexcept {
24 printf(
"EUI48Sub mac02_sub: '%s' -> '%s'\n", mac_sub_str.c_str(), mac_sub.
toString().c_str());
27 std::string sub_str(mac_sub_str);
28 if( sub_str.size() == 0 ) {
30 }
else if( sub_str !=
":" ) {
31 if( sub_str.size() > 0 && sub_str[0] ==
':' ) {
32 sub_str = sub_str.substr(1, sub_str.size());
34 if( sub_str.size() > 0 && sub_str[sub_str.size()-1] ==
':' ) {
35 sub_str = sub_str.substr(0, sub_str.size()-1);
38 REQUIRE(sub_str == mac_sub.
toString());
41 REQUIRE( idx == indices.
at(i));
54static void test_sub02(
const std::string& mac_sub_str_exp,
const std::string& mac_sub_str,
const bool expected_result) {
59 printf(
"EUI48Sub mac_sub: '%s' -> '%s'\n", mac_sub_str.c_str(), mac_sub.
toString().c_str());
60 if( expected_result ) {
61 REQUIRE(mac_sub_str_exp == mac_sub.
toString());
64 printf(
"EUI48Sub mac_sub: '%s' -> Error '%s'\n", mac_sub_str.c_str(), errmsg.c_str());
66 REQUIRE( expected_result == res );
71 INFO_STR(
"EUI48 size: whole0 "+std::to_string(
sizeof(
EUI48)));
72 INFO_STR(
"EUI48 size: whole1 "+std::to_string(
sizeof(mac01)));
73 INFO_STR(
"EUI48 size: data1 "+std::to_string(
sizeof(mac01.
b)));
74 REQUIRE_MSG(
"EUI48 struct and data size match",
sizeof(
EUI48) ==
sizeof(mac01));
75 REQUIRE_MSG(
"EUI48 struct and data size match",
sizeof(mac01) ==
sizeof(mac01.
b));
79 const std::string mac02_str =
"C0:10:22:A0:10:00";
80 const jau::darray<std::string> mac02_sub_strs = {
"C0",
"C0:10",
":10:22",
"10:22",
":10:22:",
"10:22:",
"10",
"10:00",
"00",
":",
"",
"00:10", mac02_str};
81 const jau::darray<jau::snsize_t> mac02_sub_idxs_le = { 5, 4, 3, 3, 3, 3, 1, 0, 0, 0, 0, -1, 0};
82 const jau::darray<jau::snsize_t> mac02_sub_idxs_be = { 0, 0, 1, 1, 1, 1, 4, 4, 5, 0, 0, -1, 0};
89 const std::string mac03_str =
"01:02:03:04:05:06";
90 const jau::darray<std::string> mac03_sub_strs = {
"01",
"01:02",
":03:04",
"03:04",
":04:05:",
"04:05:",
"04",
"05:06",
"06",
":",
"",
"06:05", mac03_str};
91 const jau::darray<jau::snsize_t> mac03_sub_idxs_le = { 5, 4, 2, 2, 1, 1, 2, 0, 0, 0, 0, -1, 0};
92 const jau::darray<jau::snsize_t> mac03_sub_idxs_be = { 0, 0, 2, 2, 3, 3, 3, 4, 5, 0, 0, -1, 0};
97 const std::string mac_sub_str =
"C0:10:22:A0:10:00";
101 const std::string mac_sub_str =
"0600106";
102 const std::string dummy;
106 EUI48 h(
"01:02:03:04:05:06");
108 INFO_STR(
"EUI48 indexOf: h "+h.toString()+
", n "+n.
toString());
113 EUI48 h(
"01:02:03:04:05:06");
115 INFO_STR(
"EUI48 indexOf: h "+h.toString()+
", n "+n.
toString());
static bool scanEUI48Sub(const std::string &str, EUI48Sub &dest, std::string &errmsg)
Fills given EUI48Sub instance via given string representation.
static void test_sub01(const lb_endian_t byte_order, const std::string &mac_str, const jau::darray< std::string > &mac_sub_strs, const jau::darray< jau::snsize_t > &indices)