|
@@ -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) {
|