summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2019-09-06 15:27:22 +0200
committerThomas Markwalder <tmark@isc.org>2019-09-06 15:29:48 +0200
commit60baf65d0c9de384b0da147b50b7fc3180fc54dd (patch)
tree248d4505f95a5aef511320430b16b788b2a77f8d
parent[#821,!501] kea-dhcp4 now sanity checks inbound messages (diff)
downloadkea-60baf65d0c9de384b0da147b50b7fc3180fc54dd.tar.xz
kea-60baf65d0c9de384b0da147b50b7fc3180fc54dd.zip
[#821,!501] Addressed review comments
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc Cleaned up failure text src/lib/testutils/gtest_utils.h Replaced array with vector
-rw-r--r--src/bin/dhcp4/tests/dhcp4_srv_unittest.cc20
-rw-r--r--src/lib/testutils/gtest_utils.h8
2 files changed, 14 insertions, 14 deletions
diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
index 5c0b5d186b..07e6fe6d9d 100644
--- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
@@ -730,8 +730,8 @@ TEST_F(Dhcpv4SrvTest, sanityCheckDiscover) {
" provided in message DHCPDISCOVER");
// Add a hardware address. This should not throw.
- uint8_t data[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
- HWAddrPtr hwaddr(new HWAddr(data, sizeof(data), HTYPE_ETHER));
+ std::vector<uint8_t> data = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
+ HWAddrPtr hwaddr(new HWAddr(data, HTYPE_ETHER));
pkt->setHWAddr(hwaddr);
ASSERT_NO_THROW(srv.processDiscover(pkt));
@@ -767,8 +767,8 @@ TEST_F(Dhcpv4SrvTest, sanityCheckRequest) {
" provided in message DHCPREQUEST");
// Add a hardware address. Should not throw.
- uint8_t data[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
- HWAddrPtr hwaddr(new HWAddr(data, sizeof(data), HTYPE_ETHER));
+ std::vector<uint8_t> data = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
+ HWAddrPtr hwaddr(new HWAddr(data, HTYPE_ETHER));
pkt->setHWAddr(hwaddr);
EXPECT_NO_THROW(srv.processRequest(pkt));
@@ -812,8 +812,8 @@ TEST_F(Dhcpv4SrvTest, sanityCheckDecline) {
" provided in message DHCPDECLINE");
// Add a hardware address. Should throw because of missing address.
- uint8_t data[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
- HWAddrPtr hwaddr(new HWAddr(data, sizeof(data), HTYPE_ETHER));
+ std::vector<uint8_t> data = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
+ HWAddrPtr hwaddr(new HWAddr(data, HTYPE_ETHER));
pkt->setHWAddr(hwaddr);
ASSERT_THROW_MSG(srv.processDecline(pkt), RFCViolation,
"Mandatory 'Requested IP address' option missing in DHCPDECLINE"
@@ -859,8 +859,8 @@ TEST_F(Dhcpv4SrvTest, sanityCheckRelease) {
" provided in message DHCPRELEASE");
// Add a hardware address. Should not throw.
- uint8_t data[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
- HWAddrPtr hwaddr(new HWAddr(data, sizeof(data), HTYPE_ETHER));
+ std::vector<uint8_t> data = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
+ HWAddrPtr hwaddr(new HWAddr(data, HTYPE_ETHER));
pkt->setHWAddr(hwaddr);
EXPECT_NO_THROW(srv.processRelease(pkt));
@@ -894,8 +894,8 @@ TEST_F(Dhcpv4SrvTest, sanityCheckInform) {
" provided in message DHCPINFORM");
// Add a hardware address. Should not throw.
- uint8_t data[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
- HWAddrPtr hwaddr(new HWAddr(data, sizeof(data), HTYPE_ETHER));
+ std::vector<uint8_t> data = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
+ HWAddrPtr hwaddr(new HWAddr(data, HTYPE_ETHER));
pkt->setHWAddr(hwaddr);
ASSERT_NO_THROW(srv.processInform(pkt));
diff --git a/src/lib/testutils/gtest_utils.h b/src/lib/testutils/gtest_utils.h
index c8820b0aa0..7f7bfb4839 100644
--- a/src/lib/testutils/gtest_utils.h
+++ b/src/lib/testutils/gtest_utils.h
@@ -25,11 +25,11 @@ namespace test {
{ \
try { \
statement; \
- ADD_FAILURE() << "no exception, expected:" << #etype; \
+ ADD_FAILURE() << "no exception, expected: " << #etype; \
} catch (const etype& ex) { \
EXPECT_EQ(std::string(ex.what()), emsg); \
} catch (...) { \
- ADD_FAILURE() << "wrong exception type thrown, expected " << #etype; \
+ ADD_FAILURE() << "wrong exception type thrown, expected: " << #etype; \
} \
} \
@@ -46,11 +46,11 @@ namespace test {
{ \
try { \
statement; \
- GTEST_FAIL() << "no exception, expected:" << #etype; \
+ GTEST_FAIL() << "no exception, expected: " << #etype; \
} catch (const etype& ex) { \
ASSERT_EQ(std::string(ex.what()), emsg); \
} catch (...) { \
- GTEST_FAIL() << "wrong exception type thrown, expected " << #etype; \
+ GTEST_FAIL() << "wrong exception type thrown, expected: " << #etype; \
} \
} \