summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcp_ddns/tests/ncr_unittests.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2013-09-02 17:20:34 +0200
committerMarcin Siodelski <marcin@isc.org>2013-09-02 17:20:34 +0200
commitecd5a9bc58e0f15933f5508afec02a0d48ba342e (patch)
tree83730fbf5f2b719f98c719685f6b4358f659c32f /src/lib/dhcp_ddns/tests/ncr_unittests.cc
parent[3035] Implemented DHCPv4 srv function to process an FQDN option. (diff)
downloadkea-ecd5a9bc58e0f15933f5508afec02a0d48ba342e.tar.xz
kea-ecd5a9bc58e0f15933f5508afec02a0d48ba342e.zip
[3035] Added functions to construct DHCID object from raw buffer.
Diffstat (limited to 'src/lib/dhcp_ddns/tests/ncr_unittests.cc')
-rw-r--r--src/lib/dhcp_ddns/tests/ncr_unittests.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/dhcp_ddns/tests/ncr_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_unittests.cc
index df1a50a69a..418658e1cc 100644
--- a/src/lib/dhcp_ddns/tests/ncr_unittests.cc
+++ b/src/lib/dhcp_ddns/tests/ncr_unittests.cc
@@ -387,6 +387,32 @@ TEST(NameChangeRequestTest, dhcidFromMaxDUID) {
EXPECT_EQ(dhcid_ref, dhcid.toStr());
}
+// Test that DHCID is correctly created from the buffer holding DHCID data
+// in raw format.
+TEST(NameChangeRequestTest, dhcidFromBytes) {
+ // Create a buffer holding raw DHCID data.
+ std::vector<uint8_t> dhcid_data;
+ for (int i = 0; i < 64; ++i) {
+ dhcid_data.push_back(i);
+ }
+ // Construct new object and initialize it with the DHCID data.
+ D2Dhcid dhcid(dhcid_data);
+
+ // Make sure that the DHCID is valid.
+ EXPECT_TRUE(std::equal(dhcid.getBytes().begin(), dhcid.getBytes().end(),
+ dhcid_data.begin()));
+
+ // Modify the buffer and reinitialize DHCID with the new buffer.
+ for (int i = 64; i < 128; ++i) {
+ dhcid_data.push_back(i);
+ }
+ ASSERT_NO_THROW(dhcid.fromBytes(dhcid_data));
+
+ // Make sure that the DHCID is still valid.
+ EXPECT_TRUE(std::equal(dhcid.getBytes().begin(), dhcid.getBytes().end(),
+ dhcid_data.begin()));
+
+}
/// @brief Verifies the fundamentals of converting from and to JSON.
/// It verifies that: