mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 13:07:50 +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:
parent
351dbdab09
commit
26f89e5cc9
@ -23,8 +23,8 @@
|
||||
#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_int_array.h>
|
||||
#include <dhcp/pkt6.h>
|
||||
#include <dhcp6/dhcp6_log.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
|
||||
// get this option from client's message.
|
||||
boost::shared_ptr<Option6IntArray<uint16_t> > option_oro =
|
||||
boost::dynamic_pointer_cast<Option6IntArray<uint16_t> >(question->getOption(D6O_ORO));
|
||||
boost::shared_ptr<OptionIntArray<uint16_t> > option_oro =
|
||||
boost::dynamic_pointer_cast<OptionIntArray<uint16_t> >(question->getOption(D6O_ORO));
|
||||
// Option ORO not found. Don't do anything then.
|
||||
if (!option_oro) {
|
||||
return;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <dhcp/option6_addrlst.h>
|
||||
#include <dhcp/option6_ia.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/dhcp6_srv.h>
|
||||
#include <dhcpsrv/cfgmgr.h>
|
||||
@ -351,8 +351,8 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) {
|
||||
|
||||
// Let's now request option with code 1000.
|
||||
// We expect that server will include this option in its reply.
|
||||
boost::shared_ptr<Option6IntArray<uint16_t> >
|
||||
option_oro(new Option6IntArray<uint16_t>(D6O_ORO));
|
||||
boost::shared_ptr<OptionIntArray<uint16_t> >
|
||||
option_oro(new OptionIntArray<uint16_t>(D6O_ORO));
|
||||
// Create vector with two option codes.
|
||||
std::vector<uint16_t> codes(2);
|
||||
codes[0] = 1000;
|
||||
|
@ -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 += option4_addrlst.cc option4_addrlst.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 += pkt6.cc pkt6.h
|
||||
libb10_dhcp___la_SOURCES += pkt4.cc pkt4.h
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include <dhcp/option.h>
|
||||
#include <dhcp/option6_ia.h>
|
||||
#include <dhcp/option6_iaaddr.h>
|
||||
#include <dhcp/option6_int_array.h>
|
||||
#include <dhcp/option_definition.h>
|
||||
#include <dhcp/option_int_array.h>
|
||||
#include <dhcp/std_option_defs.h>
|
||||
#include <exceptions/exceptions.h>
|
||||
#include <util/buffer.h>
|
||||
|
@ -70,7 +70,7 @@ enum OptionDataType {
|
||||
/// @brief Trait class for data types supported in DHCP option definitions.
|
||||
///
|
||||
/// 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.
|
||||
template<typename T>
|
||||
struct OptionDataTypeTraits {
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include <dhcp/option6_addrlst.h>
|
||||
#include <dhcp/option6_ia.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_definition.h>
|
||||
#include <dhcp/option_int.h>
|
||||
#include <dhcp/option_int_array.h>
|
||||
#include <util/encode/hex.h>
|
||||
|
||||
using namespace std;
|
||||
|
@ -51,22 +51,22 @@ typedef boost::shared_ptr<OptionDefinition> OptionDefinitionPtr;
|
||||
/// @brief Forward declaration to OptionInt.
|
||||
///
|
||||
/// 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
|
||||
/// inclusion between libdhcp++.h, option_definition.h and
|
||||
/// option6_int.h.
|
||||
template<typename T>
|
||||
class OptionInt;
|
||||
|
||||
/// @brief Forward declaration to Option6IntArray.
|
||||
/// @brief Forward declaration to OptionIntArray.
|
||||
///
|
||||
/// This forward declaration is needed to access Option6IntArray class
|
||||
/// without having to include option6_int_array.h header. This is because
|
||||
/// This forward declaration is needed to access OptionIntArray class
|
||||
/// without having to include option_int_array.h header. This is because
|
||||
/// this header includes libdhcp++.h and this causes circular
|
||||
/// inclusion between libdhcp++.h, option_definition.h and
|
||||
/// option6_int_array.h.
|
||||
/// option_int_array.h.
|
||||
template<typename T>
|
||||
class Option6IntArray;
|
||||
class OptionIntArray;
|
||||
|
||||
/// @brief Base class representing a DHCP option definition.
|
||||
///
|
||||
@ -371,7 +371,7 @@ public:
|
||||
static OptionPtr factoryIntegerArray(uint16_t type,
|
||||
OptionBufferConstIter begin,
|
||||
OptionBufferConstIter end) {
|
||||
OptionPtr option(new Option6IntArray<T>(type, begin, end));
|
||||
OptionPtr option(new OptionIntArray<T>(type, begin, end));
|
||||
return (option);
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
#ifndef OPTION6_INT_ARRAY_H
|
||||
#define OPTION6_INT_ARRAY_H
|
||||
#ifndef OPTION_INT_ARRAY_H
|
||||
#define OPTION_INT_ARRAY_H
|
||||
|
||||
#include <dhcp/libdhcp++.h>
|
||||
#include <dhcp/option.h>
|
||||
@ -25,9 +25,9 @@
|
||||
namespace isc {
|
||||
namespace dhcp {
|
||||
|
||||
/// This template class represents DHCPv6 option with array of
|
||||
/// integer values. The type of the elements in the array can be
|
||||
/// any of the following:
|
||||
/// This template class represents DHCP (v4 or v6) option with an
|
||||
/// array of integer values. The type of the elements in the array
|
||||
/// can be any of the following:
|
||||
/// - uint8_t,
|
||||
/// - uint16_t,
|
||||
/// - uint32_t,
|
||||
@ -43,7 +43,7 @@ namespace dhcp {
|
||||
///
|
||||
/// @param T data field type (see above).
|
||||
template<typename T>
|
||||
class Option6IntArray: public Option {
|
||||
class OptionIntArray: public Option {
|
||||
|
||||
public:
|
||||
|
||||
@ -55,7 +55,7 @@ public:
|
||||
///
|
||||
/// @throw isc::dhcp::InvalidDataType if data field type provided
|
||||
/// as template parameter is not a supported integer type.
|
||||
Option6IntArray(uint16_t type)
|
||||
OptionIntArray(uint16_t type)
|
||||
: Option(Option::V6, type),
|
||||
values_(0) {
|
||||
if (!OptionDataTypeTraits<T>::integer_type) {
|
||||
@ -72,7 +72,7 @@ public:
|
||||
/// is not multiple of size of the data type in bytes.
|
||||
/// @throw isc::dhcp::InvalidDataType if data field type provided
|
||||
/// 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) {
|
||||
if (!OptionDataTypeTraits<T>::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.
|
||||
/// @throw isc::dhcp::InvalidDataType if data field type provided
|
||||
/// as template parameter is not a supported integer type.
|
||||
Option6IntArray(uint16_t type, OptionBufferConstIter begin,
|
||||
OptionIntArray(uint16_t type, OptionBufferConstIter begin,
|
||||
OptionBufferConstIter end)
|
||||
: Option(Option::V6, type) {
|
||||
if (!OptionDataTypeTraits<T>::integer_type) {
|
||||
@ -225,4 +225,4 @@ private:
|
||||
} // isc::dhcp namespace
|
||||
} // isc namespace
|
||||
|
||||
#endif // OPTION6_INT_ARRAY_H
|
||||
#endif // OPTION_INT_ARRAY_H
|
@ -25,7 +25,7 @@ namespace {
|
||||
/// @param name name of the array being declared.
|
||||
/// @param types data types of fields that belong to the record.
|
||||
#ifndef RECORD_DECL
|
||||
#define RECORD_DECL(name, types...) static const OptionDataType name[] = { types }
|
||||
#define RECORD_DECL(name, types...) static OptionDataType name[] = { types }
|
||||
#endif
|
||||
|
||||
/// @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
|
||||
// by OPT_FQDN_TYPE but we can't use it here because
|
||||
// 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.
|
||||
static const OptionDefParams OPTION_DEF_PARAMS4[] = {
|
||||
|
@ -33,8 +33,8 @@ libdhcp___unittests_SOURCES += option4_addrlst_unittest.cc
|
||||
libdhcp___unittests_SOURCES += option6_addrlst_unittest.cc
|
||||
libdhcp___unittests_SOURCES += option6_ia_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_array_unittest.cc
|
||||
libdhcp___unittests_SOURCES += option_data_types_unittest.cc
|
||||
libdhcp___unittests_SOURCES += option_definition_unittest.cc
|
||||
libdhcp___unittests_SOURCES += option_custom_unittest.cc
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include <dhcp/option6_addrlst.h>
|
||||
#include <dhcp/option6_ia.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_int.h>
|
||||
#include <dhcp/option_int_array.h>
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@ -288,11 +288,11 @@ TEST_F(LibDhcpTest, unpackOptions6) {
|
||||
EXPECT_EQ(6, x->second->getType()); // this should be option 6
|
||||
ASSERT_EQ(8, x->second->len()); // it should be of length 8
|
||||
// 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
|
||||
// returned pointer to this type to get values stored in it.
|
||||
boost::shared_ptr<Option6IntArray<uint16_t> > opt_oro =
|
||||
boost::dynamic_pointer_cast<Option6IntArray<uint16_t> >(x->second);
|
||||
boost::shared_ptr<OptionIntArray<uint16_t> > opt_oro =
|
||||
boost::dynamic_pointer_cast<OptionIntArray<uint16_t> >(x->second);
|
||||
// This value will be NULL if cast was unsuccessful. This is the case
|
||||
// when returned option has different type than expected.
|
||||
ASSERT_TRUE(opt_oro);
|
||||
@ -632,7 +632,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
|
||||
LibDhcpTest::testStdOptionDefs6(D6O_IAADDR, buf, typeid(Option6IAAddr));
|
||||
|
||||
LibDhcpTest::testStdOptionDefs6(D6O_ORO, buf,
|
||||
typeid(Option6IntArray<uint16_t>));
|
||||
typeid(OptionIntArray<uint16_t>));
|
||||
|
||||
LibDhcpTest::testStdOptionDefs6(D6O_PREFERENCE, buf,
|
||||
typeid(OptionInt<uint8_t>));
|
||||
@ -723,7 +723,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
|
||||
typeid(OptionCustom));
|
||||
|
||||
LibDhcpTest::testStdOptionDefs6(D6O_ERO, buf,
|
||||
typeid(Option6IntArray<uint16_t>));
|
||||
typeid(OptionIntArray<uint16_t>));
|
||||
|
||||
LibDhcpTest::testStdOptionDefs6(D6O_LQ_QUERY, buf, typeid(OptionCustom));
|
||||
|
||||
|
@ -21,10 +21,10 @@
|
||||
#include <dhcp/option6_addrlst.h>
|
||||
#include <dhcp/option6_ia.h>
|
||||
#include <dhcp/option6_iaaddr.h>
|
||||
#include <dhcp/option6_int_array.h>
|
||||
#include <dhcp/option_custom.h>
|
||||
#include <dhcp/option_definition.h>
|
||||
#include <dhcp/option_int.h>
|
||||
#include <dhcp/option_int_array.h>
|
||||
#include <exceptions/exceptions.h>
|
||||
|
||||
#include <boost/pointer_cast.hpp>
|
||||
@ -740,9 +740,9 @@ TEST_F(OptionDefinitionTest, uint16Array) {
|
||||
EXPECT_NO_THROW(
|
||||
option_v6 = opt_def.optionFactory(Option::V6, opt_code, buf);
|
||||
);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint16_t>));
|
||||
boost::shared_ptr<Option6IntArray<uint16_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<Option6IntArray<uint16_t> >(option_v6);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint16_t>));
|
||||
boost::shared_ptr<OptionIntArray<uint16_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<OptionIntArray<uint16_t> >(option_v6);
|
||||
// Get the values from the initiated options and validate.
|
||||
std::vector<uint16_t> values = option_cast_v6->getValues();
|
||||
for (int i = 0; i < values.size(); ++i) {
|
||||
@ -782,9 +782,9 @@ TEST_F(OptionDefinitionTest, uint16ArrayTokenized) {
|
||||
EXPECT_NO_THROW(
|
||||
option_v6 = opt_def.optionFactory(Option::V6, opt_code, str_values);
|
||||
);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint16_t>));
|
||||
boost::shared_ptr<Option6IntArray<uint16_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<Option6IntArray<uint16_t> >(option_v6);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint16_t>));
|
||||
boost::shared_ptr<OptionIntArray<uint16_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<OptionIntArray<uint16_t> >(option_v6);
|
||||
// Get the values from the initiated options and validate.
|
||||
std::vector<uint16_t> values = option_cast_v6->getValues();
|
||||
EXPECT_EQ(12345, values[0]);
|
||||
@ -813,9 +813,9 @@ TEST_F(OptionDefinitionTest, uint32Array) {
|
||||
EXPECT_NO_THROW(
|
||||
option_v6 = opt_def.optionFactory(Option::V6, opt_code, buf);
|
||||
);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint32_t>));
|
||||
boost::shared_ptr<Option6IntArray<uint32_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<Option6IntArray<uint32_t> >(option_v6);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint32_t>));
|
||||
boost::shared_ptr<OptionIntArray<uint32_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<OptionIntArray<uint32_t> >(option_v6);
|
||||
// Get the values from the initiated options and validate.
|
||||
std::vector<uint32_t> values = option_cast_v6->getValues();
|
||||
for (int i = 0; i < values.size(); ++i) {
|
||||
@ -858,9 +858,9 @@ TEST_F(OptionDefinitionTest, uint32ArrayTokenized) {
|
||||
EXPECT_NO_THROW(
|
||||
option_v6 = opt_def.optionFactory(Option::V6, opt_code, str_values);
|
||||
);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(Option6IntArray<uint32_t>));
|
||||
boost::shared_ptr<Option6IntArray<uint32_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<Option6IntArray<uint32_t> >(option_v6);
|
||||
ASSERT_TRUE(typeid(*option_v6) == typeid(OptionIntArray<uint32_t>));
|
||||
boost::shared_ptr<OptionIntArray<uint32_t> > option_cast_v6 =
|
||||
boost::static_pointer_cast<OptionIntArray<uint32_t> >(option_v6);
|
||||
// Get the values from the initiated options and validate.
|
||||
std::vector<uint32_t> values = option_cast_v6->getValues();
|
||||
EXPECT_EQ(123456, values[0]);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <dhcp/dhcp6.h>
|
||||
#include <dhcp/option.h>
|
||||
#include <dhcp/option6_iaaddr.h>
|
||||
#include <dhcp/option6_int_array.h>
|
||||
#include <dhcp/option_int_array.h>
|
||||
#include <util/buffer.h>
|
||||
|
||||
#include <boost/pointer_cast.hpp>
|
||||
@ -31,13 +31,13 @@ using namespace isc::util;
|
||||
|
||||
namespace {
|
||||
|
||||
/// @brief Option6IntArray test class.
|
||||
class Option6IntArrayTest : public ::testing::Test {
|
||||
/// @brief OptionIntArray test class.
|
||||
class OptionIntArrayTest : public ::testing::Test {
|
||||
public:
|
||||
/// @brief Constructor.
|
||||
///
|
||||
/// 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++) {
|
||||
buf_[i] = 255 - i;
|
||||
}
|
||||
@ -57,21 +57,21 @@ public:
|
||||
// returns the buffer which is actually the array of uint8_t.
|
||||
// However, since we allow using uint8_t types with this template
|
||||
// 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 uint16_t opt_code = 80;
|
||||
|
||||
// Constructor throws exception if provided buffer is empty.
|
||||
EXPECT_THROW(
|
||||
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin()),
|
||||
OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin()),
|
||||
isc::OutOfRange
|
||||
);
|
||||
|
||||
// Provided buffer is not empty so it should not throw exception.
|
||||
ASSERT_NO_THROW(
|
||||
opt = boost::shared_ptr<
|
||||
Option6IntArray<T> >(new Option6IntArray<T>(opt_code, buf_.begin(),
|
||||
buf_.begin() + opt_len))
|
||||
OptionIntArray<T> >(new OptionIntArray<T>(opt_code, buf_.begin(),
|
||||
buf_.begin() + opt_len))
|
||||
);
|
||||
|
||||
EXPECT_EQ(Option::V6, opt->getUniverse());
|
||||
@ -124,28 +124,28 @@ public:
|
||||
template<typename T>
|
||||
void bufferToIntTest16() {
|
||||
// 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 uint16_t opt_code = 81;
|
||||
|
||||
// Constructor throws exception if provided buffer is empty.
|
||||
EXPECT_THROW(
|
||||
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin()),
|
||||
OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin()),
|
||||
isc::OutOfRange
|
||||
);
|
||||
|
||||
// Constructor throws exception if provided buffer's length is not
|
||||
// multiple of 2-bytes.
|
||||
EXPECT_THROW(
|
||||
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin() + 5),
|
||||
OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin() + 5),
|
||||
isc::OutOfRange
|
||||
);
|
||||
|
||||
// Now the buffer length is correct.
|
||||
ASSERT_NO_THROW(
|
||||
opt = boost::shared_ptr<
|
||||
Option6IntArray<T> >(new Option6IntArray<T>(opt_code, buf_.begin(),
|
||||
buf_.begin() + opt_len))
|
||||
OptionIntArray<T> >(new OptionIntArray<T>(opt_code, buf_.begin(),
|
||||
buf_.begin() + opt_len))
|
||||
);
|
||||
|
||||
EXPECT_EQ(Option::V6, opt->getUniverse());
|
||||
@ -195,28 +195,28 @@ public:
|
||||
template<typename T>
|
||||
void bufferToIntTest32() {
|
||||
// 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 uint16_t opt_code = 82;
|
||||
|
||||
// Constructor throws exception if provided buffer is empty.
|
||||
EXPECT_THROW(
|
||||
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin()),
|
||||
OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin()),
|
||||
isc::OutOfRange
|
||||
);
|
||||
|
||||
// Constructor throws exception if provided buffer's length is not
|
||||
// multiple of 4-bytes.
|
||||
EXPECT_THROW(
|
||||
Option6IntArray<T>(opt_code, buf_.begin(), buf_.begin() + 9),
|
||||
OptionIntArray<T>(opt_code, buf_.begin(), buf_.begin() + 9),
|
||||
isc::OutOfRange
|
||||
);
|
||||
|
||||
// Now the buffer length is correct.
|
||||
ASSERT_NO_THROW(
|
||||
opt = boost::shared_ptr<
|
||||
Option6IntArray<T> >(new Option6IntArray<T>(opt_code, buf_.begin(),
|
||||
buf_.begin() + opt_len))
|
||||
OptionIntArray<T> >(new OptionIntArray<T>(opt_code, buf_.begin(),
|
||||
buf_.begin() + opt_len))
|
||||
);
|
||||
|
||||
EXPECT_EQ(Option::V6, opt->getUniverse());
|
||||
@ -268,51 +268,51 @@ public:
|
||||
/// convey unsigned values. We should maybe extend these tests for
|
||||
/// signed types too.
|
||||
|
||||
TEST_F(Option6IntArrayTest, useInvalidType) {
|
||||
TEST_F(OptionIntArrayTest, useInvalidType) {
|
||||
const uint16_t opt_code = 80;
|
||||
EXPECT_THROW(
|
||||
boost::scoped_ptr<
|
||||
Option6IntArray<bool> >(new Option6IntArray<bool>(opt_code, OptionBuffer(5))),
|
||||
OptionIntArray<bool> >(new OptionIntArray<bool>(opt_code, OptionBuffer(5))),
|
||||
InvalidDataType
|
||||
);
|
||||
|
||||
EXPECT_THROW(
|
||||
boost::scoped_ptr<
|
||||
Option6IntArray<int64_t> >(new Option6IntArray<int64_t>(opt_code,
|
||||
OptionBuffer(10))),
|
||||
OptionIntArray<int64_t> >(new OptionIntArray<int64_t>(opt_code,
|
||||
OptionBuffer(10))),
|
||||
InvalidDataType
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, bufferToUint8) {
|
||||
TEST_F(OptionIntArrayTest, bufferToUint8) {
|
||||
bufferToIntTest8<uint8_t>();
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, bufferToInt8) {
|
||||
TEST_F(OptionIntArrayTest, bufferToInt8) {
|
||||
bufferToIntTest8<int8_t>();
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, bufferToUint16) {
|
||||
TEST_F(OptionIntArrayTest, bufferToUint16) {
|
||||
bufferToIntTest16<uint16_t>();
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, bufferToInt16) {
|
||||
TEST_F(OptionIntArrayTest, bufferToInt16) {
|
||||
bufferToIntTest16<int16_t>();
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, bufferToUint32) {
|
||||
TEST_F(OptionIntArrayTest, bufferToUint32) {
|
||||
bufferToIntTest32<uint32_t>();
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, bufferToInt32) {
|
||||
TEST_F(OptionIntArrayTest, bufferToInt32) {
|
||||
bufferToIntTest32<int32_t>();
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, setValuesUint8) {
|
||||
TEST_F(OptionIntArrayTest, setValuesUint8) {
|
||||
const uint16_t opt_code = 100;
|
||||
// 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.
|
||||
std::vector<uint8_t> values;
|
||||
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()));
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, setValuesInt8) {
|
||||
TEST_F(OptionIntArrayTest, setValuesInt8) {
|
||||
const uint16_t opt_code = 100;
|
||||
// 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.
|
||||
std::vector<int8_t> values;
|
||||
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()));
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, setValuesUint16) {
|
||||
TEST_F(OptionIntArrayTest, setValuesUint16) {
|
||||
const uint16_t opt_code = 101;
|
||||
// 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.
|
||||
std::vector<uint16_t> values;
|
||||
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()));
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, setValuesInt16) {
|
||||
TEST_F(OptionIntArrayTest, setValuesInt16) {
|
||||
const uint16_t opt_code = 101;
|
||||
// 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.
|
||||
std::vector<int16_t> values;
|
||||
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()));
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, setValuesUint32) {
|
||||
TEST_F(OptionIntArrayTest, setValuesUint32) {
|
||||
const uint32_t opt_code = 101;
|
||||
// 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.
|
||||
std::vector<uint32_t> values;
|
||||
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()));
|
||||
}
|
||||
|
||||
TEST_F(Option6IntArrayTest, setValuesInt32) {
|
||||
TEST_F(OptionIntArrayTest, setValuesInt32) {
|
||||
const uint32_t opt_code = 101;
|
||||
// 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.
|
||||
std::vector<int32_t> values;
|
||||
for (int i = 0; i < 10; ++i) {
|
Loading…
x
Reference in New Issue
Block a user