]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[564-customer-request-relax-constraints-on-allowable-option-types-to-permit-option...
authorFrancis Dupont <fdupont@isc.org>
Wed, 17 Apr 2019 18:35:34 +0000 (20:35 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 18 Apr 2019 14:48:12 +0000 (16:48 +0200)
src/lib/dhcp/tests/libdhcp++_unittest.cc

index 64ce61def9370e1ae3329cabb67b0812a036310a..58f1656d162c2169b5ca8b2ce48b6a3aa8a4d099 100644 (file)
@@ -551,12 +551,10 @@ TEST_F(LibDhcpTest, unpackEmptyOption6) {
     LibDHCP::commitRuntimeOptionDefs();
 
     // Create the buffer holding the structure of the empty option.
-    const uint8_t raw_data[] = {
+    OptionBuffer buf = {
       0x04, 0x00,                // option code = 1024
       0x00, 0x00                 // option length = 0
     };
-    size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t);
-    OptionBuffer buf(raw_data, raw_data + raw_data_len);
 
     // Parse options.
     OptionCollection options;
@@ -599,7 +597,7 @@ TEST_F(LibDhcpTest, unpackSubOptions6) {
     LibDHCP::commitRuntimeOptionDefs();
 
     // Create the buffer holding the structure of options.
-    const char raw_data[] = {
+    OptionBuffer buf = {
         // First option starts here.
         0x00, 0x01,   // option code = 1
         0x00, 0x0F,   // option length = 15
@@ -613,7 +611,6 @@ TEST_F(LibDhcpTest, unpackSubOptions6) {
         0x00, 0x01,  // option length = 1
         0x00 // This option carries a single uint8 value and has no sub options.
     };
-    OptionBuffer buf(raw_data, raw_data + sizeof(raw_data));
 
     // Parse options.
     OptionCollection options;
@@ -919,12 +916,10 @@ TEST_F(LibDhcpTest, unpackEmptyOption4) {
     LibDHCP::commitRuntimeOptionDefs();
 
     // Create the buffer holding the structure of the empty option.
-    const uint8_t raw_data[] = {
+    OptionBuffer buf = {
       0xFE,                     // option code = 254
       0x00                      // option length = 0
     };
-    size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t);
-    OptionBuffer buf(raw_data, raw_data + raw_data_len);
 
     // Parse options.
     OptionCollection options;
@@ -969,7 +964,7 @@ TEST_F(LibDhcpTest, unpackSubOptions4) {
     LibDHCP::commitRuntimeOptionDefs();
 
     // Create the buffer holding the structure of options.
-    const uint8_t raw_data[] = {
+    OptionBuffer buf = {
         // First option starts here.
         0x01,                   // option code = 1
         0x0B,                   // option length = 11
@@ -984,8 +979,6 @@ TEST_F(LibDhcpTest, unpackSubOptions4) {
         0x00                    // This option carries a single uint8
                                 // value and has no sub options.
     };
-    size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t);
-    OptionBuffer buf(raw_data, raw_data + raw_data_len);
 
     // Parse options.
     OptionCollection options;
@@ -1042,7 +1035,7 @@ TEST_F(LibDhcpTest, unpackPadEnd) {
     LibDHCP::commitRuntimeOptionDefs();
 
     // Create the buffer holding the structure of options.
-    const uint8_t raw_data[] = {
+    OptionBuffer buf = {
         // Add a PAD
         0x00,                         // option code = 0 (PAD)
         // Container option starts here.
@@ -1059,8 +1052,6 @@ TEST_F(LibDhcpTest, unpackPadEnd) {
         // Extra bytes at tail.
         0x01, 0x02, 0x03, 0x04
     };
-    size_t raw_data_len = sizeof(raw_data) / sizeof(uint8_t);
-    OptionBuffer buf(raw_data, raw_data + raw_data_len);
 
     // Parse options.
     OptionCollection options;
@@ -1070,7 +1061,7 @@ TEST_F(LibDhcpTest, unpackPadEnd) {
                                                      options, deferred));
 
     // Returned offset should point to the END.
-    EXPECT_EQ(0xff, raw_data[offset]);
+    EXPECT_EQ(0xff, buf[offset]);
 
     // There should be one top level option.
     ASSERT_EQ(1, options.size());
@@ -1081,7 +1072,7 @@ TEST_F(LibDhcpTest, unpackPadEnd) {
     EXPECT_EQ(200, option->getType());
 
     // There should be 3 suboptions.
-    EXPECT_EQ(3, option->getOptions().size());
+    ASSERT_EQ(3, option->getOptions().size());
 
     // Get suboption 0.
     boost::shared_ptr<OptionInt<uint8_t> > sub0 =