2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[2526] Renamed Option6IntArray to OptionIntArray.

... as this class is going to be used either for V6 or V4 now.
This commit is contained in:
Marcin Siodelski
2012-12-11 13:12:33 +01:00
parent 351dbdab09
commit 26f89e5cc9
13 changed files with 91 additions and 91 deletions

View File

@@ -23,8 +23,8 @@
#include <dhcp/option6_ia.h> #include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h>
#include <dhcp/option_custom.h> #include <dhcp/option_custom.h>
#include <dhcp/option_int_array.h>
#include <dhcp/pkt6.h> #include <dhcp/pkt6.h>
#include <dhcp6/dhcp6_log.h> #include <dhcp6/dhcp6_log.h>
#include <dhcp6/dhcp6_srv.h> #include <dhcp6/dhcp6_srv.h>
@@ -327,8 +327,8 @@ void Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer)
// Client requests some options using ORO option. Try to // Client requests some options using ORO option. Try to
// get this option from client's message. // get this option from client's message.
boost::shared_ptr<Option6IntArray<uint16_t> > option_oro = boost::shared_ptr<OptionIntArray<uint16_t> > option_oro =
boost::dynamic_pointer_cast<Option6IntArray<uint16_t> >(question->getOption(D6O_ORO)); boost::dynamic_pointer_cast<OptionIntArray<uint16_t> >(question->getOption(D6O_ORO));
// Option ORO not found. Don't do anything then. // Option ORO not found. Don't do anything then.
if (!option_oro) { if (!option_oro) {
return; return;

View File

@@ -22,7 +22,7 @@
#include <dhcp/option6_addrlst.h> #include <dhcp/option6_addrlst.h>
#include <dhcp/option6_ia.h> #include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h> #include <dhcp/option_int_array.h>
#include <dhcp6/config_parser.h> #include <dhcp6/config_parser.h>
#include <dhcp6/dhcp6_srv.h> #include <dhcp6/dhcp6_srv.h>
#include <dhcpsrv/cfgmgr.h> #include <dhcpsrv/cfgmgr.h>
@@ -351,8 +351,8 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) {
// Let's now request option with code 1000. // Let's now request option with code 1000.
// We expect that server will include this option in its reply. // We expect that server will include this option in its reply.
boost::shared_ptr<Option6IntArray<uint16_t> > boost::shared_ptr<OptionIntArray<uint16_t> >
option_oro(new Option6IntArray<uint16_t>(D6O_ORO)); option_oro(new OptionIntArray<uint16_t>(D6O_ORO));
// Create vector with two option codes. // Create vector with two option codes.
std::vector<uint16_t> codes(2); std::vector<uint16_t> codes(2);
codes[0] = 1000; codes[0] = 1000;

View File

@@ -29,7 +29,7 @@ libb10_dhcp___la_SOURCES += option6_iaaddr.cc option6_iaaddr.h
libb10_dhcp___la_SOURCES += option6_addrlst.cc option6_addrlst.h libb10_dhcp___la_SOURCES += option6_addrlst.cc option6_addrlst.h
libb10_dhcp___la_SOURCES += option4_addrlst.cc option4_addrlst.h libb10_dhcp___la_SOURCES += option4_addrlst.cc option4_addrlst.h
libb10_dhcp___la_SOURCES += option_int.h libb10_dhcp___la_SOURCES += option_int.h
libb10_dhcp___la_SOURCES += option6_int_array.h libb10_dhcp___la_SOURCES += option_int_array.h
libb10_dhcp___la_SOURCES += dhcp6.h dhcp4.h libb10_dhcp___la_SOURCES += dhcp6.h dhcp4.h
libb10_dhcp___la_SOURCES += pkt6.cc pkt6.h libb10_dhcp___la_SOURCES += pkt6.cc pkt6.h
libb10_dhcp___la_SOURCES += pkt4.cc pkt4.h libb10_dhcp___la_SOURCES += pkt4.cc pkt4.h

View File

@@ -20,8 +20,8 @@
#include <dhcp/option.h> #include <dhcp/option.h>
#include <dhcp/option6_ia.h> #include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h>
#include <dhcp/option_definition.h> #include <dhcp/option_definition.h>
#include <dhcp/option_int_array.h>
#include <dhcp/std_option_defs.h> #include <dhcp/std_option_defs.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
#include <util/buffer.h> #include <util/buffer.h>

View File

@@ -70,7 +70,7 @@ enum OptionDataType {
/// @brief Trait class for data types supported in DHCP option definitions. /// @brief Trait class for data types supported in DHCP option definitions.
/// ///
/// This is useful to check whether the type specified as template parameter /// This is useful to check whether the type specified as template parameter
/// is supported by classes like Option6Int, Option6IntArray and some template /// is supported by classes like OptionInt, OptionIntArray and some template
/// factory functions in OptionDefinition class. /// factory functions in OptionDefinition class.
template<typename T> template<typename T>
struct OptionDataTypeTraits { struct OptionDataTypeTraits {

View File

@@ -17,10 +17,10 @@
#include <dhcp/option6_addrlst.h> #include <dhcp/option6_addrlst.h>
#include <dhcp/option6_ia.h> #include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h>
#include <dhcp/option_int.h>
#include <dhcp/option_custom.h> #include <dhcp/option_custom.h>
#include <dhcp/option_definition.h> #include <dhcp/option_definition.h>
#include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
#include <util/encode/hex.h> #include <util/encode/hex.h>
using namespace std; using namespace std;

View File

@@ -51,22 +51,22 @@ typedef boost::shared_ptr<OptionDefinition> OptionDefinitionPtr;
/// @brief Forward declaration to OptionInt. /// @brief Forward declaration to OptionInt.
/// ///
/// This forward declaration is needed to access OptionInt class /// This forward declaration is needed to access OptionInt class
/// without having to include option6_int.h header. This is because /// without having to include option_int.h header. This is because
/// this header includes libdhcp++.h and this causes circular /// this header includes libdhcp++.h and this causes circular
/// inclusion between libdhcp++.h, option_definition.h and /// inclusion between libdhcp++.h, option_definition.h and
/// option6_int.h. /// option6_int.h.
template<typename T> template<typename T>
class OptionInt; class OptionInt;
/// @brief Forward declaration to Option6IntArray. /// @brief Forward declaration to OptionIntArray.
/// ///
/// This forward declaration is needed to access Option6IntArray class /// This forward declaration is needed to access OptionIntArray class
/// without having to include option6_int_array.h header. This is because /// without having to include option_int_array.h header. This is because
/// this header includes libdhcp++.h and this causes circular /// this header includes libdhcp++.h and this causes circular
/// inclusion between libdhcp++.h, option_definition.h and /// inclusion between libdhcp++.h, option_definition.h and
/// option6_int_array.h. /// option_int_array.h.
template<typename T> template<typename T>
class Option6IntArray; class OptionIntArray;
/// @brief Base class representing a DHCP option definition. /// @brief Base class representing a DHCP option definition.
/// ///
@@ -371,7 +371,7 @@ public:
static OptionPtr factoryIntegerArray(uint16_t type, static OptionPtr factoryIntegerArray(uint16_t type,
OptionBufferConstIter begin, OptionBufferConstIter begin,
OptionBufferConstIter end) { OptionBufferConstIter end) {
OptionPtr option(new Option6IntArray<T>(type, begin, end)); OptionPtr option(new OptionIntArray<T>(type, begin, end));
return (option); return (option);
} }

View File

@@ -12,8 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE. // PERFORMANCE OF THIS SOFTWARE.
#ifndef OPTION6_INT_ARRAY_H #ifndef OPTION_INT_ARRAY_H
#define OPTION6_INT_ARRAY_H #define OPTION_INT_ARRAY_H
#include <dhcp/libdhcp++.h> #include <dhcp/libdhcp++.h>
#include <dhcp/option.h> #include <dhcp/option.h>
@@ -25,9 +25,9 @@
namespace isc { namespace isc {
namespace dhcp { namespace dhcp {
/// This template class represents DHCPv6 option with array of /// This template class represents DHCP (v4 or v6) option with an
/// integer values. The type of the elements in the array can be /// array of integer values. The type of the elements in the array
/// any of the following: /// can be any of the following:
/// - uint8_t, /// - uint8_t,
/// - uint16_t, /// - uint16_t,
/// - uint32_t, /// - uint32_t,
@@ -43,7 +43,7 @@ namespace dhcp {
/// ///
/// @param T data field type (see above). /// @param T data field type (see above).
template<typename T> template<typename T>
class Option6IntArray: public Option { class OptionIntArray: public Option {
public: public:
@@ -55,7 +55,7 @@ public:
/// ///
/// @throw isc::dhcp::InvalidDataType if data field type provided /// @throw isc::dhcp::InvalidDataType if data field type provided
/// as template parameter is not a supported integer type. /// as template parameter is not a supported integer type.
Option6IntArray(uint16_t type) OptionIntArray(uint16_t type)
: Option(Option::V6, type), : Option(Option::V6, type),
values_(0) { values_(0) {
if (!OptionDataTypeTraits<T>::integer_type) { if (!OptionDataTypeTraits<T>::integer_type) {
@@ -72,7 +72,7 @@ public:
/// is not multiple of size of the data type in bytes. /// is not multiple of size of the data type in bytes.
/// @throw isc::dhcp::InvalidDataType if data field type provided /// @throw isc::dhcp::InvalidDataType if data field type provided
/// as template parameter is not a supported integer type. /// as template parameter is not a supported integer type.
Option6IntArray(uint16_t type, const OptionBuffer& buf) OptionIntArray(uint16_t type, const OptionBuffer& buf)
: Option(Option::V6, type) { : Option(Option::V6, type) {
if (!OptionDataTypeTraits<T>::integer_type) { if (!OptionDataTypeTraits<T>::integer_type) {
isc_throw(dhcp::InvalidDataType, "non-integer type"); isc_throw(dhcp::InvalidDataType, "non-integer type");
@@ -94,7 +94,7 @@ public:
/// is not multiple of size of the data type in bytes. /// is not multiple of size of the data type in bytes.
/// @throw isc::dhcp::InvalidDataType if data field type provided /// @throw isc::dhcp::InvalidDataType if data field type provided
/// as template parameter is not a supported integer type. /// as template parameter is not a supported integer type.
Option6IntArray(uint16_t type, OptionBufferConstIter begin, OptionIntArray(uint16_t type, OptionBufferConstIter begin,
OptionBufferConstIter end) OptionBufferConstIter end)
: Option(Option::V6, type) { : Option(Option::V6, type) {
if (!OptionDataTypeTraits<T>::integer_type) { if (!OptionDataTypeTraits<T>::integer_type) {
@@ -225,4 +225,4 @@ private:
} // isc::dhcp namespace } // isc::dhcp namespace
} // isc namespace } // isc namespace
#endif // OPTION6_INT_ARRAY_H #endif // OPTION_INT_ARRAY_H

View File

@@ -25,7 +25,7 @@ namespace {
/// @param name name of the array being declared. /// @param name name of the array being declared.
/// @param types data types of fields that belong to the record. /// @param types data types of fields that belong to the record.
#ifndef RECORD_DECL #ifndef RECORD_DECL
#define RECORD_DECL(name, types...) static const OptionDataType name[] = { types } #define RECORD_DECL(name, types...) static OptionDataType name[] = { types }
#endif #endif
/// @brief A pair of values: one pointing to the array holding types of /// @brief A pair of values: one pointing to the array holding types of
@@ -56,7 +56,7 @@ struct OptionDefParams {
// RFC 1035, section 3.1. The latter could be handled // RFC 1035, section 3.1. The latter could be handled
// by OPT_FQDN_TYPE but we can't use it here because // by OPT_FQDN_TYPE but we can't use it here because
// clients may request ASCII encoding. // clients may request ASCII encoding.
RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_STRING_TYPE) RECORD_DECL(FQDN_RECORDS, OPT_UINT8_TYPE, OPT_UINT8_TYPE, OPT_STRING_TYPE);
/// @brief Definitions of standard DHCPv4 options. /// @brief Definitions of standard DHCPv4 options.
static const OptionDefParams OPTION_DEF_PARAMS4[] = { static const OptionDefParams OPTION_DEF_PARAMS4[] = {

View File

@@ -33,8 +33,8 @@ libdhcp___unittests_SOURCES += option4_addrlst_unittest.cc
libdhcp___unittests_SOURCES += option6_addrlst_unittest.cc libdhcp___unittests_SOURCES += option6_addrlst_unittest.cc
libdhcp___unittests_SOURCES += option6_ia_unittest.cc libdhcp___unittests_SOURCES += option6_ia_unittest.cc
libdhcp___unittests_SOURCES += option6_iaaddr_unittest.cc libdhcp___unittests_SOURCES += option6_iaaddr_unittest.cc
libdhcp___unittests_SOURCES += option6_int_array_unittest.cc
libdhcp___unittests_SOURCES += option_int_unittest.cc libdhcp___unittests_SOURCES += option_int_unittest.cc
libdhcp___unittests_SOURCES += option_int_array_unittest.cc
libdhcp___unittests_SOURCES += option_data_types_unittest.cc libdhcp___unittests_SOURCES += option_data_types_unittest.cc
libdhcp___unittests_SOURCES += option_definition_unittest.cc libdhcp___unittests_SOURCES += option_definition_unittest.cc
libdhcp___unittests_SOURCES += option_custom_unittest.cc libdhcp___unittests_SOURCES += option_custom_unittest.cc

View File

@@ -20,9 +20,9 @@
#include <dhcp/option6_addrlst.h> #include <dhcp/option6_addrlst.h>
#include <dhcp/option6_ia.h> #include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h>
#include <dhcp/option_int.h>
#include <dhcp/option_custom.h> #include <dhcp/option_custom.h>
#include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
#include <util/buffer.h> #include <util/buffer.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -288,11 +288,11 @@ TEST_F(LibDhcpTest, unpackOptions6) {
EXPECT_EQ(6, x->second->getType()); // this should be option 6 EXPECT_EQ(6, x->second->getType()); // this should be option 6
ASSERT_EQ(8, x->second->len()); // it should be of length 8 ASSERT_EQ(8, x->second->len()); // it should be of length 8
// Option with code 6 is the OPTION_ORO. This option is // Option with code 6 is the OPTION_ORO. This option is
// represented by the Option6IntArray<uint16_t> class which // represented by the OptionIntArray<uint16_t> class which
// comprises the set of uint16_t values. We need to cast the // comprises the set of uint16_t values. We need to cast the
// returned pointer to this type to get values stored in it. // returned pointer to this type to get values stored in it.
boost::shared_ptr<Option6IntArray<uint16_t> > opt_oro = boost::shared_ptr<OptionIntArray<uint16_t> > opt_oro =
boost::dynamic_pointer_cast<Option6IntArray<uint16_t> >(x->second); boost::dynamic_pointer_cast<OptionIntArray<uint16_t> >(x->second);
// This value will be NULL if cast was unsuccessful. This is the case // This value will be NULL if cast was unsuccessful. This is the case
// when returned option has different type than expected. // when returned option has different type than expected.
ASSERT_TRUE(opt_oro); ASSERT_TRUE(opt_oro);
@@ -632,7 +632,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
LibDhcpTest::testStdOptionDefs6(D6O_IAADDR, buf, typeid(Option6IAAddr)); LibDhcpTest::testStdOptionDefs6(D6O_IAADDR, buf, typeid(Option6IAAddr));
LibDhcpTest::testStdOptionDefs6(D6O_ORO, buf, LibDhcpTest::testStdOptionDefs6(D6O_ORO, buf,
typeid(Option6IntArray<uint16_t>)); typeid(OptionIntArray<uint16_t>));
LibDhcpTest::testStdOptionDefs6(D6O_PREFERENCE, buf, LibDhcpTest::testStdOptionDefs6(D6O_PREFERENCE, buf,
typeid(OptionInt<uint8_t>)); typeid(OptionInt<uint8_t>));
@@ -723,7 +723,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
typeid(OptionCustom)); typeid(OptionCustom));
LibDhcpTest::testStdOptionDefs6(D6O_ERO, buf, LibDhcpTest::testStdOptionDefs6(D6O_ERO, buf,
typeid(Option6IntArray<uint16_t>)); typeid(OptionIntArray<uint16_t>));
LibDhcpTest::testStdOptionDefs6(D6O_LQ_QUERY, buf, typeid(OptionCustom)); LibDhcpTest::testStdOptionDefs6(D6O_LQ_QUERY, buf, typeid(OptionCustom));

View File

@@ -21,10 +21,10 @@
#include <dhcp/option6_addrlst.h> #include <dhcp/option6_addrlst.h>
#include <dhcp/option6_ia.h> #include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h>
#include <dhcp/option_custom.h> #include <dhcp/option_custom.h>
#include <dhcp/option_definition.h> #include <dhcp/option_definition.h>
#include <dhcp/option_int.h> #include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
#include <exceptions/exceptions.h> #include <exceptions/exceptions.h>
#include <boost/pointer_cast.hpp> #include <boost/pointer_cast.hpp>
@@ -740,9 +740,9 @@ TEST_F(OptionDefinitionTest, uint16Array) {
EXPECT_NO_THROW( EXPECT_NO_THROW(
option_v6 = opt_def.optionFactory(Option::V6, opt_code, buf); option_v6 = opt_def.optionFactory(Option::V6, opt_code, buf);
); );
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint16_t>)); ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint16_t>));
boost::shared_ptr<Option6IntArray<uint16_t> > option_cast_v6 = boost::shared_ptr<OptionIntArray<uint16_t> > option_cast_v6 =
boost::static_pointer_cast<Option6IntArray<uint16_t> >(option_v6); boost::static_pointer_cast<OptionIntArray<uint16_t> >(option_v6);
// Get the values from the initiated options and validate. // Get the values from the initiated options and validate.
std::vector<uint16_t> values = option_cast_v6->getValues(); std::vector<uint16_t> values = option_cast_v6->getValues();
for (int i = 0; i < values.size(); ++i) { for (int i = 0; i < values.size(); ++i) {
@@ -782,9 +782,9 @@ TEST_F(OptionDefinitionTest, uint16ArrayTokenized) {
EXPECT_NO_THROW( EXPECT_NO_THROW(
option_v6 = opt_def.optionFactory(Option::V6, opt_code, str_values); option_v6 = opt_def.optionFactory(Option::V6, opt_code, str_values);
); );
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint16_t>)); ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint16_t>));
boost::shared_ptr<Option6IntArray<uint16_t> > option_cast_v6 = boost::shared_ptr<OptionIntArray<uint16_t> > option_cast_v6 =
boost::static_pointer_cast<Option6IntArray<uint16_t> >(option_v6); boost::static_pointer_cast<OptionIntArray<uint16_t> >(option_v6);
// Get the values from the initiated options and validate. // Get the values from the initiated options and validate.
std::vector<uint16_t> values = option_cast_v6->getValues(); std::vector<uint16_t> values = option_cast_v6->getValues();
EXPECT_EQ(12345, values[0]); EXPECT_EQ(12345, values[0]);
@@ -813,9 +813,9 @@ TEST_F(OptionDefinitionTest, uint32Array) {
EXPECT_NO_THROW( EXPECT_NO_THROW(
option_v6 = opt_def.optionFactory(Option::V6, opt_code, buf); option_v6 = opt_def.optionFactory(Option::V6, opt_code, buf);
); );
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint32_t>)); ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint32_t>));
boost::shared_ptr<Option6IntArray<uint32_t> > option_cast_v6 = boost::shared_ptr<OptionIntArray<uint32_t> > option_cast_v6 =
boost::static_pointer_cast<Option6IntArray<uint32_t> >(option_v6); boost::static_pointer_cast<OptionIntArray<uint32_t> >(option_v6);
// Get the values from the initiated options and validate. // Get the values from the initiated options and validate.
std::vector<uint32_t> values = option_cast_v6->getValues(); std::vector<uint32_t> values = option_cast_v6->getValues();
for (int i = 0; i < values.size(); ++i) { for (int i = 0; i < values.size(); ++i) {
@@ -858,9 +858,9 @@ TEST_F(OptionDefinitionTest, uint32ArrayTokenized) {
EXPECT_NO_THROW( EXPECT_NO_THROW(
option_v6 = opt_def.optionFactory(Option::V6, opt_code, str_values); option_v6 = opt_def.optionFactory(Option::V6, opt_code, str_values);
); );
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint32_t>)); ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint32_t>));
boost::shared_ptr<Option6IntArray<uint32_t> > option_cast_v6 = boost::shared_ptr<OptionIntArray<uint32_t> > option_cast_v6 =
boost::static_pointer_cast<Option6IntArray<uint32_t> >(option_v6); boost::static_pointer_cast<OptionIntArray<uint32_t> >(option_v6);
// Get the values from the initiated options and validate. // Get the values from the initiated options and validate.
std::vector<uint32_t> values = option_cast_v6->getValues(); std::vector<uint32_t> values = option_cast_v6->getValues();
EXPECT_EQ(123456, values[0]); EXPECT_EQ(123456, values[0]);

View File

@@ -17,7 +17,7 @@
#include <dhcp/dhcp6.h> #include <dhcp/dhcp6.h>
#include <dhcp/option.h> #include <dhcp/option.h>
#include <dhcp/option6_iaaddr.h> #include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_int_array.h> #include <dhcp/option_int_array.h>
#include <util/buffer.h> #include <util/buffer.h>
#include <boost/pointer_cast.hpp> #include <boost/pointer_cast.hpp>
@@ -31,13 +31,13 @@ using namespace isc::util;
namespace { namespace {
/// @brief Option6IntArray test class. /// @brief OptionIntArray test class.
class Option6IntArrayTest : public ::testing::Test { class OptionIntArrayTest : public ::testing::Test {
public: public:
/// @brief Constructor. /// @brief Constructor.
/// ///
/// Initializes the option buffer with some data. /// Initializes the option buffer with some data.
Option6IntArrayTest(): buf_(255), out_buf_(255) { OptionIntArrayTest(): buf_(255), out_buf_(255) {
for (int i = 0; i < 255; i++) { for (int i = 0; i < 255; i++) {
buf_[i] = 255 - i; buf_[i] = 255 - i;
} }
@@ -57,20 +57,20 @@ public:
// returns the buffer which is actually the array of uint8_t. // returns the buffer which is actually the array of uint8_t.
// However, since we allow using uint8_t types with this template // However, since we allow using uint8_t types with this template
// class we have to test it here. // class we have to test it here.
boost::shared_ptr<Option6IntArray<T> > opt; boost::shared_ptr<OptionIntArray<T> > opt;
const int opt_len = 10; const int opt_len = 10;
const uint16_t opt_code = 80; const uint16_t opt_code = 80;
// Constructor throws exception if provided buffer is empty. // Constructor throws exception if provided buffer is empty.
EXPECT_THROW( EXPECT_THROW(
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin()), OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin()),
isc::OutOfRange isc::OutOfRange
); );
// Provided buffer is not empty so it should not throw exception. // Provided buffer is not empty so it should not throw exception.
ASSERT_NO_THROW( ASSERT_NO_THROW(
opt = boost::shared_ptr< opt = boost::shared_ptr<
Option6IntArray<T> >(new Option6IntArray<T>(opt_code, buf_.begin(), OptionIntArray<T> >(new OptionIntArray<T>(opt_code, buf_.begin(),
buf_.begin() + opt_len)) buf_.begin() + opt_len))
); );
@@ -124,27 +124,27 @@ public:
template<typename T> template<typename T>
void bufferToIntTest16() { void bufferToIntTest16() {
// Create option that conveys array of multiple uint16_t or int16_t values. // Create option that conveys array of multiple uint16_t or int16_t values.
boost::shared_ptr<Option6IntArray<T> > opt; boost::shared_ptr<OptionIntArray<T> > opt;
const int opt_len = 20; const int opt_len = 20;
const uint16_t opt_code = 81; const uint16_t opt_code = 81;
// Constructor throws exception if provided buffer is empty. // Constructor throws exception if provided buffer is empty.
EXPECT_THROW( EXPECT_THROW(
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin()), OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin()),
isc::OutOfRange isc::OutOfRange
); );
// Constructor throws exception if provided buffer's length is not // Constructor throws exception if provided buffer's length is not
// multiple of 2-bytes. // multiple of 2-bytes.
EXPECT_THROW( EXPECT_THROW(
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin() + 5), OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin() + 5),
isc::OutOfRange isc::OutOfRange
); );
// Now the buffer length is correct. // Now the buffer length is correct.
ASSERT_NO_THROW( ASSERT_NO_THROW(
opt = boost::shared_ptr< opt = boost::shared_ptr<
Option6IntArray<T> >(new Option6IntArray<T>(opt_code, buf_.begin(), OptionIntArray<T> >(new OptionIntArray<T>(opt_code, buf_.begin(),
buf_.begin() + opt_len)) buf_.begin() + opt_len))
); );
@@ -195,27 +195,27 @@ public:
template<typename T> template<typename T>
void bufferToIntTest32() { void bufferToIntTest32() {
// Create option that conveys array of multiple uint16_t values. // Create option that conveys array of multiple uint16_t values.
boost::shared_ptr<Option6IntArray<T> > opt; boost::shared_ptr<OptionIntArray<T> > opt;
const int opt_len = 40; const int opt_len = 40;
const uint16_t opt_code = 82; const uint16_t opt_code = 82;
// Constructor throws exception if provided buffer is empty. // Constructor throws exception if provided buffer is empty.
EXPECT_THROW( EXPECT_THROW(
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin()), OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin()),
isc::OutOfRange isc::OutOfRange
); );
// Constructor throws exception if provided buffer's length is not // Constructor throws exception if provided buffer's length is not
// multiple of 4-bytes. // multiple of 4-bytes.
EXPECT_THROW( EXPECT_THROW(
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin() + 9), OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin() + 9),
isc::OutOfRange isc::OutOfRange
); );
// Now the buffer length is correct. // Now the buffer length is correct.
ASSERT_NO_THROW( ASSERT_NO_THROW(
opt = boost::shared_ptr< opt = boost::shared_ptr<
Option6IntArray<T> >(new Option6IntArray<T>(opt_code, buf_.begin(), OptionIntArray<T> >(new OptionIntArray<T>(opt_code, buf_.begin(),
buf_.begin() + opt_len)) buf_.begin() + opt_len))
); );
@@ -268,51 +268,51 @@ public:
/// convey unsigned values. We should maybe extend these tests for /// convey unsigned values. We should maybe extend these tests for
/// signed types too. /// signed types too.
TEST_F(Option6IntArrayTest, useInvalidType) { TEST_F(OptionIntArrayTest, useInvalidType) {
const uint16_t opt_code = 80; const uint16_t opt_code = 80;
EXPECT_THROW( EXPECT_THROW(
boost::scoped_ptr< boost::scoped_ptr<
Option6IntArray<bool> >(new Option6IntArray<bool>(opt_code, OptionBuffer(5))), OptionIntArray<bool> >(new OptionIntArray<bool>(opt_code, OptionBuffer(5))),
InvalidDataType InvalidDataType
); );
EXPECT_THROW( EXPECT_THROW(
boost::scoped_ptr< boost::scoped_ptr<
Option6IntArray<int64_t> >(new Option6IntArray<int64_t>(opt_code, OptionIntArray<int64_t> >(new OptionIntArray<int64_t>(opt_code,
OptionBuffer(10))), OptionBuffer(10))),
InvalidDataType InvalidDataType
); );
} }
TEST_F(Option6IntArrayTest, bufferToUint8) { TEST_F(OptionIntArrayTest, bufferToUint8) {
bufferToIntTest8<uint8_t>(); bufferToIntTest8<uint8_t>();
} }
TEST_F(Option6IntArrayTest, bufferToInt8) { TEST_F(OptionIntArrayTest, bufferToInt8) {
bufferToIntTest8<int8_t>(); bufferToIntTest8<int8_t>();
} }
TEST_F(Option6IntArrayTest, bufferToUint16) { TEST_F(OptionIntArrayTest, bufferToUint16) {
bufferToIntTest16<uint16_t>(); bufferToIntTest16<uint16_t>();
} }
TEST_F(Option6IntArrayTest, bufferToInt16) { TEST_F(OptionIntArrayTest, bufferToInt16) {
bufferToIntTest16<int16_t>(); bufferToIntTest16<int16_t>();
} }
TEST_F(Option6IntArrayTest, bufferToUint32) { TEST_F(OptionIntArrayTest, bufferToUint32) {
bufferToIntTest32<uint32_t>(); bufferToIntTest32<uint32_t>();
} }
TEST_F(Option6IntArrayTest, bufferToInt32) { TEST_F(OptionIntArrayTest, bufferToInt32) {
bufferToIntTest32<int32_t>(); bufferToIntTest32<int32_t>();
} }
TEST_F(Option6IntArrayTest, setValuesUint8) { TEST_F(OptionIntArrayTest, setValuesUint8) {
const uint16_t opt_code = 100; const uint16_t opt_code = 100;
// Create option with empty vector of values. // Create option with empty vector of values.
boost::shared_ptr<Option6IntArray<uint8_t> > opt(new Option6IntArray<uint8_t>(opt_code)); boost::shared_ptr<OptionIntArray<uint8_t> > opt(new OptionIntArray<uint8_t>(opt_code));
// Initialize vector with some data and pass to the option. // Initialize vector with some data and pass to the option.
std::vector<uint8_t> values; std::vector<uint8_t> values;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@@ -327,10 +327,10 @@ TEST_F(Option6IntArrayTest, setValuesUint8) {
EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin())); EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin()));
} }
TEST_F(Option6IntArrayTest, setValuesInt8) { TEST_F(OptionIntArrayTest, setValuesInt8) {
const uint16_t opt_code = 100; const uint16_t opt_code = 100;
// Create option with empty vector of values. // Create option with empty vector of values.
boost::shared_ptr<Option6IntArray<int8_t> > opt(new Option6IntArray<int8_t>(opt_code)); boost::shared_ptr<OptionIntArray<int8_t> > opt(new OptionIntArray<int8_t>(opt_code));
// Initialize vector with some data and pass to the option. // Initialize vector with some data and pass to the option.
std::vector<int8_t> values; std::vector<int8_t> values;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@@ -345,10 +345,10 @@ TEST_F(Option6IntArrayTest, setValuesInt8) {
EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin())); EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin()));
} }
TEST_F(Option6IntArrayTest, setValuesUint16) { TEST_F(OptionIntArrayTest, setValuesUint16) {
const uint16_t opt_code = 101; const uint16_t opt_code = 101;
// Create option with empty vector of values. // Create option with empty vector of values.
boost::shared_ptr<Option6IntArray<uint16_t> > opt(new Option6IntArray<uint16_t>(opt_code)); boost::shared_ptr<OptionIntArray<uint16_t> > opt(new OptionIntArray<uint16_t>(opt_code));
// Initialize vector with some data and pass to the option. // Initialize vector with some data and pass to the option.
std::vector<uint16_t> values; std::vector<uint16_t> values;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@@ -363,10 +363,10 @@ TEST_F(Option6IntArrayTest, setValuesUint16) {
EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin())); EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin()));
} }
TEST_F(Option6IntArrayTest, setValuesInt16) { TEST_F(OptionIntArrayTest, setValuesInt16) {
const uint16_t opt_code = 101; const uint16_t opt_code = 101;
// Create option with empty vector of values. // Create option with empty vector of values.
boost::shared_ptr<Option6IntArray<int16_t> > opt(new Option6IntArray<int16_t>(opt_code)); boost::shared_ptr<OptionIntArray<int16_t> > opt(new OptionIntArray<int16_t>(opt_code));
// Initialize vector with some data and pass to the option. // Initialize vector with some data and pass to the option.
std::vector<int16_t> values; std::vector<int16_t> values;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@@ -381,10 +381,10 @@ TEST_F(Option6IntArrayTest, setValuesInt16) {
EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin())); EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin()));
} }
TEST_F(Option6IntArrayTest, setValuesUint32) { TEST_F(OptionIntArrayTest, setValuesUint32) {
const uint32_t opt_code = 101; const uint32_t opt_code = 101;
// Create option with empty vector of values. // Create option with empty vector of values.
boost::shared_ptr<Option6IntArray<uint32_t> > opt(new Option6IntArray<uint32_t>(opt_code)); boost::shared_ptr<OptionIntArray<uint32_t> > opt(new OptionIntArray<uint32_t>(opt_code));
// Initialize vector with some data and pass to the option. // Initialize vector with some data and pass to the option.
std::vector<uint32_t> values; std::vector<uint32_t> values;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
@@ -399,10 +399,10 @@ TEST_F(Option6IntArrayTest, setValuesUint32) {
EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin())); EXPECT_TRUE(std::equal(values.begin(), values.end(), returned_values.begin()));
} }
TEST_F(Option6IntArrayTest, setValuesInt32) { TEST_F(OptionIntArrayTest, setValuesInt32) {
const uint32_t opt_code = 101; const uint32_t opt_code = 101;
// Create option with empty vector of values. // Create option with empty vector of values.
boost::shared_ptr<Option6IntArray<int32_t> > opt(new Option6IntArray<int32_t>(opt_code)); boost::shared_ptr<OptionIntArray<int32_t> > opt(new OptionIntArray<int32_t>(opt_code));
// Initialize vector with some data and pass to the option. // Initialize vector with some data and pass to the option.
std::vector<int32_t> values; std::vector<int32_t> values;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {