5 #include <gtest/gtest.h> 14 uint8_t data[] = {0x01,0x23,0x45,0x67,0x89,0xab};
15 EXPECT_STRNE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xab).toString().c_str(),
MacAddr().toString().c_str());
16 EXPECT_STREQ(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xab).toString().c_str(),
MacAddr(data).toString().c_str());
23 EXPECT_STREQ(
"00:00:00:00:00:00",
MacAddr().toString().c_str());
26 EXPECT_STREQ(
"00:00:00:00:00:00",
MacAddr(0x00,0x00,0x00,0x00,0x00,0x00).toString(
true).c_str());
27 EXPECT_STREQ(
"01:01:01:01:01:01",
MacAddr(0x01,0x01,0x01,0x01,0x01,0x01).toString(
true).c_str());
28 EXPECT_STREQ(
"02:02:02:02:02:02",
MacAddr(0x02,0x02,0x02,0x02,0x02,0x02).toString(
true).c_str());
29 EXPECT_STREQ(
"03:03:03:03:03:03",
MacAddr(0x03,0x03,0x03,0x03,0x03,0x03).toString(
true).c_str());
30 EXPECT_STREQ(
"04:04:04:04:04:04",
MacAddr(0x04,0x04,0x04,0x04,0x04,0x04).toString(
true).c_str());
31 EXPECT_STREQ(
"05:05:05:05:05:05",
MacAddr(0x05,0x05,0x05,0x05,0x05,0x05).toString(
true).c_str());
32 EXPECT_STREQ(
"06:06:06:06:06:06",
MacAddr(0x06,0x06,0x06,0x06,0x06,0x06).toString(
true).c_str());
33 EXPECT_STREQ(
"07:07:07:07:07:07",
MacAddr(0x07,0x07,0x07,0x07,0x07,0x07).toString(
true).c_str());
34 EXPECT_STREQ(
"08:08:08:08:08:08",
MacAddr(0x08,0x08,0x08,0x08,0x08,0x08).toString(
true).c_str());
35 EXPECT_STREQ(
"09:09:09:09:09:09",
MacAddr(0x09,0x09,0x09,0x09,0x09,0x09).toString(
true).c_str());
36 EXPECT_STREQ(
"0A:0A:0A:0A:0A:0A",
MacAddr(0x0A,0x0A,0x0A,0x0A,0x0A,0x0A).toString(
true).c_str());
37 EXPECT_STREQ(
"0B:0B:0B:0B:0B:0B",
MacAddr(0x0B,0x0B,0x0B,0x0B,0x0B,0x0B).toString(
true).c_str());
38 EXPECT_STREQ(
"0C:0C:0C:0C:0C:0C",
MacAddr(0x0C,0x0C,0x0C,0x0C,0x0C,0x0C).toString(
true).c_str());
39 EXPECT_STREQ(
"0D:0D:0D:0D:0D:0D",
MacAddr(0x0D,0x0D,0x0D,0x0D,0x0D,0x0D).toString(
true).c_str());
40 EXPECT_STREQ(
"0E:0E:0E:0E:0E:0E",
MacAddr(0x0E,0x0E,0x0E,0x0E,0x0E,0x0E).toString(
true).c_str());
41 EXPECT_STREQ(
"0F:0F:0F:0F:0F:0F",
MacAddr(0x0F,0x0F,0x0F,0x0F,0x0F,0x0F).toString(
true).c_str());
42 EXPECT_STREQ(
"10:10:10:10:10:10",
MacAddr(0x10,0x10,0x10,0x10,0x10,0x10).toString(
true).c_str());
43 EXPECT_STREQ(
"20:20:20:20:20:20",
MacAddr(0x20,0x20,0x20,0x20,0x20,0x20).toString(
true).c_str());
44 EXPECT_STREQ(
"30:30:30:30:30:30",
MacAddr(0x30,0x30,0x30,0x30,0x30,0x30).toString(
true).c_str());
45 EXPECT_STREQ(
"40:40:40:40:40:40",
MacAddr(0x40,0x40,0x40,0x40,0x40,0x40).toString(
true).c_str());
46 EXPECT_STREQ(
"50:50:50:50:50:50",
MacAddr(0x50,0x50,0x50,0x50,0x50,0x50).toString(
true).c_str());
47 EXPECT_STREQ(
"60:60:60:60:60:60",
MacAddr(0x60,0x60,0x60,0x60,0x60,0x60).toString(
true).c_str());
48 EXPECT_STREQ(
"70:70:70:70:70:70",
MacAddr(0x70,0x70,0x70,0x70,0x70,0x70).toString(
true).c_str());
49 EXPECT_STREQ(
"80:80:80:80:80:80",
MacAddr(0x80,0x80,0x80,0x80,0x80,0x80).toString(
true).c_str());
50 EXPECT_STREQ(
"90:90:90:90:90:90",
MacAddr(0x90,0x90,0x90,0x90,0x90,0x90).toString(
true).c_str());
51 EXPECT_STREQ(
"A0:A0:A0:A0:A0:A0",
MacAddr(0xA0,0xA0,0xA0,0xA0,0xA0,0xA0).toString(
true).c_str());
52 EXPECT_STREQ(
"B0:B0:B0:B0:B0:B0",
MacAddr(0xB0,0xB0,0xB0,0xB0,0xB0,0xB0).toString(
true).c_str());
53 EXPECT_STREQ(
"C0:C0:C0:C0:C0:C0",
MacAddr(0xC0,0xC0,0xC0,0xC0,0xC0,0xC0).toString(
true).c_str());
54 EXPECT_STREQ(
"D0:D0:D0:D0:D0:D0",
MacAddr(0xD0,0xD0,0xD0,0xD0,0xD0,0xD0).toString(
true).c_str());
55 EXPECT_STREQ(
"E0:E0:E0:E0:E0:E0",
MacAddr(0xE0,0xE0,0xE0,0xE0,0xE0,0xE0).toString(
true).c_str());
56 EXPECT_STREQ(
"F0:F0:F0:F0:F0:F0",
MacAddr(0xF0,0xF0,0xF0,0xF0,0xF0,0xF0).toString(
true).c_str());
57 EXPECT_STREQ(
"FF:FF:FF:FF:FF:FF",
MacAddr(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF).toString(
true).c_str());
60 EXPECT_STREQ(
"00:00:00:00:00:00",
MacAddr(0x00,0x00,0x00,0x00,0x00,0x00).toString(
false).c_str());
61 EXPECT_STREQ(
"01:01:01:01:01:01",
MacAddr(0x01,0x01,0x01,0x01,0x01,0x01).toString(
false).c_str());
62 EXPECT_STREQ(
"02:02:02:02:02:02",
MacAddr(0x02,0x02,0x02,0x02,0x02,0x02).toString(
false).c_str());
63 EXPECT_STREQ(
"03:03:03:03:03:03",
MacAddr(0x03,0x03,0x03,0x03,0x03,0x03).toString(
false).c_str());
64 EXPECT_STREQ(
"04:04:04:04:04:04",
MacAddr(0x04,0x04,0x04,0x04,0x04,0x04).toString(
false).c_str());
65 EXPECT_STREQ(
"05:05:05:05:05:05",
MacAddr(0x05,0x05,0x05,0x05,0x05,0x05).toString(
false).c_str());
66 EXPECT_STREQ(
"06:06:06:06:06:06",
MacAddr(0x06,0x06,0x06,0x06,0x06,0x06).toString(
false).c_str());
67 EXPECT_STREQ(
"07:07:07:07:07:07",
MacAddr(0x07,0x07,0x07,0x07,0x07,0x07).toString(
false).c_str());
68 EXPECT_STREQ(
"08:08:08:08:08:08",
MacAddr(0x08,0x08,0x08,0x08,0x08,0x08).toString(
false).c_str());
69 EXPECT_STREQ(
"09:09:09:09:09:09",
MacAddr(0x09,0x09,0x09,0x09,0x09,0x09).toString(
false).c_str());
70 EXPECT_STREQ(
"0a:0a:0a:0a:0a:0a",
MacAddr(0x0a,0x0a,0x0a,0x0a,0x0a,0x0a).toString(
false).c_str());
71 EXPECT_STREQ(
"0b:0b:0b:0b:0b:0b",
MacAddr(0x0b,0x0b,0x0b,0x0b,0x0b,0x0b).toString(
false).c_str());
72 EXPECT_STREQ(
"0c:0c:0c:0c:0c:0c",
MacAddr(0x0c,0x0c,0x0c,0x0c,0x0c,0x0c).toString(
false).c_str());
73 EXPECT_STREQ(
"0d:0d:0d:0d:0d:0d",
MacAddr(0x0d,0x0d,0x0d,0x0d,0x0d,0x0d).toString(
false).c_str());
74 EXPECT_STREQ(
"0e:0e:0e:0e:0e:0e",
MacAddr(0x0e,0x0e,0x0e,0x0e,0x0e,0x0e).toString(
false).c_str());
75 EXPECT_STREQ(
"0f:0f:0f:0f:0f:0f",
MacAddr(0x0f,0x0f,0x0f,0x0f,0x0f,0x0f).toString(
false).c_str());
76 EXPECT_STREQ(
"10:10:10:10:10:10",
MacAddr(0x10,0x10,0x10,0x10,0x10,0x10).toString(
false).c_str());
77 EXPECT_STREQ(
"20:20:20:20:20:20",
MacAddr(0x20,0x20,0x20,0x20,0x20,0x20).toString(
false).c_str());
78 EXPECT_STREQ(
"30:30:30:30:30:30",
MacAddr(0x30,0x30,0x30,0x30,0x30,0x30).toString(
false).c_str());
79 EXPECT_STREQ(
"40:40:40:40:40:40",
MacAddr(0x40,0x40,0x40,0x40,0x40,0x40).toString(
false).c_str());
80 EXPECT_STREQ(
"50:50:50:50:50:50",
MacAddr(0x50,0x50,0x50,0x50,0x50,0x50).toString(
false).c_str());
81 EXPECT_STREQ(
"60:60:60:60:60:60",
MacAddr(0x60,0x60,0x60,0x60,0x60,0x60).toString(
false).c_str());
82 EXPECT_STREQ(
"70:70:70:70:70:70",
MacAddr(0x70,0x70,0x70,0x70,0x70,0x70).toString(
false).c_str());
83 EXPECT_STREQ(
"80:80:80:80:80:80",
MacAddr(0x80,0x80,0x80,0x80,0x80,0x80).toString(
false).c_str());
84 EXPECT_STREQ(
"90:90:90:90:90:90",
MacAddr(0x90,0x90,0x90,0x90,0x90,0x90).toString(
false).c_str());
85 EXPECT_STREQ(
"a0:a0:a0:a0:a0:a0",
MacAddr(0xa0,0xa0,0xa0,0xa0,0xa0,0xa0).toString(
false).c_str());
86 EXPECT_STREQ(
"b0:b0:b0:b0:b0:b0",
MacAddr(0xb0,0xb0,0xb0,0xb0,0xb0,0xb0).toString(
false).c_str());
87 EXPECT_STREQ(
"c0:c0:c0:c0:c0:c0",
MacAddr(0xc0,0xc0,0xc0,0xc0,0xc0,0xc0).toString(
false).c_str());
88 EXPECT_STREQ(
"d0:d0:d0:d0:d0:d0",
MacAddr(0xd0,0xd0,0xd0,0xd0,0xd0,0xd0).toString(
false).c_str());
89 EXPECT_STREQ(
"e0:e0:e0:e0:e0:e0",
MacAddr(0xe0,0xe0,0xe0,0xe0,0xe0,0xe0).toString(
false).c_str());
90 EXPECT_STREQ(
"f0:f0:f0:f0:f0:f0",
MacAddr(0xf0,0xf0,0xf0,0xf0,0xf0,0xf0).toString(
false).c_str());
91 EXPECT_STREQ(
"ff:ff:ff:ff:ff:ff",
MacAddr(0xff,0xff,0xff,0xff,0xff,0xff).toString(
false).c_str());
98 EXPECT_FALSE(
MacAddr(0x00,0x00,0x00,0x00,0x00,0x00).match(
MacAddr(0x00,0x00,0x00,0x00,0x00,0x00)));
99 EXPECT_FALSE(
MacAddr(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF).match(
MacAddr(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF)));
102 EXPECT_TRUE (
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB)));
103 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x00,0x23,0x45,0x67,0x89,0xAB)));
104 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x01,0x20,0x45,0x67,0x89,0xAB)));
105 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x01,0x23,0x40,0x67,0x89,0xAB)));
106 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x01,0x23,0x45,0x60,0x89,0xAB)));
107 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x01,0x23,0x45,0x67,0x80,0xAB)));
108 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xA0)));
109 EXPECT_TRUE (
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF)));
110 EXPECT_FALSE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0x0A,0xBB,0xCC,0xDD,0xEE,0xFF)));
111 EXPECT_FALSE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0xAA,0x0B,0xCC,0xDD,0xEE,0xFF)));
112 EXPECT_FALSE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0xAA,0xBB,0x0C,0xDD,0xEE,0xFF)));
113 EXPECT_FALSE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0xAA,0xBB,0xCC,0x0D,0xEE,0xFF)));
114 EXPECT_FALSE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0xAA,0xBB,0xCC,0xDD,0x0E,0xFF)));
115 EXPECT_FALSE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0x0F)));
122 EXPECT_FALSE(
MacAddr(0x00,0x00,0x00,0x00,0x00,0x00).match(
"000000000000"));
123 EXPECT_FALSE(
MacAddr(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF).match(
"FFFFFFFFFFFF"));
124 EXPECT_FALSE(
MacAddr(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF).match(
"ffffffffffff"));
127 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
""));
128 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
"0123456789A"));
129 EXPECT_TRUE (
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
"0123456789AB"));
130 EXPECT_FALSE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
"0123456789ABC"));
133 EXPECT_TRUE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
"0123456789AB"));
134 EXPECT_TRUE(
MacAddr(0x01,0x23,0x45,0x67,0x89,0xAB).match(
"0123456789ab"));
135 EXPECT_TRUE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
"aabbccddeeff"));
136 EXPECT_TRUE(
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
"AABBCCDDEEFF"));
139 EXPECT_TRUE (
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
"aa:bb:cc:dd:ee:ff"));
140 EXPECT_FALSE(
MacAddr(0x0A,0xBB,0xCC,0xDD,0xEE,0xFF).match(
"aa:bb:cc:dd:ee:ff"));
141 EXPECT_TRUE (
MacAddr(0xAA,0xBB,0xCC,0xDD,0xEE,0xFF).match(
"AA:BB:CC:DD:EE:FF"));
142 EXPECT_FALSE(
MacAddr(0x0A,0xBB,0xCC,0xDD,0xEE,0xFF).match(
"AA:BB:CC:DD:EE:FF"));
145 int main(
int argc,
char **argv)
147 testing::InitGoogleTest(&argc, argv);
148 return RUN_ALL_TESTS();
TEST(MacAddr, constructors)
int main(int argc, char **argv)