Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adam Osuchowski
Kea
Commits
cc557bae
Commit
cc557bae
authored
Dec 10, 2012
by
Marcin Siodelski
Browse files
[2526] Renamed Option6Int to OptionInt as this will be used for V4 too.
parent
e0003025
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/Makefile.am
View file @
cc557bae
...
...
@@ -28,7 +28,7 @@ libb10_dhcp___la_SOURCES += option6_ia.cc option6_ia.h
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
6
_int.h
libb10_dhcp___la_SOURCES
+=
option_int.h
libb10_dhcp___la_SOURCES
+=
option6_int_array.h
libb10_dhcp___la_SOURCES
+=
dhcp6.h dhcp4.h
libb10_dhcp___la_SOURCES
+=
pkt6.cc pkt6.h
...
...
src/lib/dhcp/option_definition.cc
View file @
cc557bae
...
...
@@ -17,8 +17,8 @@
#include
<dhcp/option6_addrlst.h>
#include
<dhcp/option6_ia.h>
#include
<dhcp/option6_iaaddr.h>
#include
<dhcp/option6_int.h>
#include
<dhcp/option6_int_array.h>
#include
<dhcp/option_int.h>
#include
<dhcp/option_custom.h>
#include
<dhcp/option_definition.h>
#include
<util/encode/hex.h>
...
...
src/lib/dhcp/option_definition.h
View file @
cc557bae
...
...
@@ -48,15 +48,15 @@ class OptionDefinition;
/// @brief Pointer to option definition object.
typedef
boost
::
shared_ptr
<
OptionDefinition
>
OptionDefinitionPtr
;
/// @brief Forward declaration to Option
6
Int.
/// @brief Forward declaration to OptionInt.
///
/// This forward declaration is needed to access Option
6
Int class
/// This forward declaration is needed to access OptionInt class
/// without having to include option6_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
Option
6
Int
;
class
OptionInt
;
/// @brief Forward declaration to Option6IntArray.
///
...
...
@@ -354,7 +354,7 @@ public:
static
OptionPtr
factoryInteger
(
Option
::
Universe
,
uint16_t
type
,
OptionBufferConstIter
begin
,
OptionBufferConstIter
end
)
{
OptionPtr
option
(
new
Option
6
Int
<
T
>
(
type
,
begin
,
end
));
OptionPtr
option
(
new
OptionInt
<
T
>
(
type
,
begin
,
end
));
return
(
option
);
}
...
...
src/lib/dhcp/option
6
_int.h
→
src/lib/dhcp/option_int.h
View file @
cc557bae
...
...
@@ -12,8 +12,8 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef OPTION
6
_INT_H
#define OPTION
6
_INT_H
#ifndef OPTION_INT_H
#define OPTION_INT_H
#include
<dhcp/libdhcp++.h>
#include
<dhcp/option.h>
...
...
@@ -25,7 +25,7 @@
namespace
isc
{
namespace
dhcp
{
/// This template class represents DHCP
v6
option with single value.
/// This template class represents DHCP option with single value.
/// This value is of integer type and can be any of the following:
/// - uint8_t,
/// - uint16_t,
...
...
@@ -36,7 +36,7 @@ namespace dhcp {
///
/// @param T data field type (see above).
template
<
typename
T
>
class
Option
6
Int
:
public
Option
{
class
OptionInt
:
public
Option
{
public:
/// @brief Constructor.
...
...
@@ -46,7 +46,7 @@ public:
///
/// @throw isc::dhcp::InvalidDataType if data field type provided
/// as template parameter is not a supported integer type.
Option
6
Int
(
uint16_t
type
,
T
value
)
OptionInt
(
uint16_t
type
,
T
value
)
:
Option
(
Option
::
V6
,
type
),
value_
(
value
)
{
if
(
!
OptionDataTypeTraits
<
T
>::
integer_type
)
{
isc_throw
(
dhcp
::
InvalidDataType
,
"non-integer type"
);
...
...
@@ -66,7 +66,7 @@ public:
/// @throw isc::OutOfRange if provided buffer is shorter than data size.
/// @throw isc::dhcp::InvalidDataType if data field type provided
/// as template parameter is not a supported integer type.
Option
6
Int
(
uint16_t
type
,
OptionBufferConstIter
begin
,
OptionInt
(
uint16_t
type
,
OptionBufferConstIter
begin
,
OptionBufferConstIter
end
)
:
Option
(
Option
::
V6
,
type
)
{
if
(
!
OptionDataTypeTraits
<
T
>::
integer_type
)
{
...
...
src/lib/dhcp/tests/Makefile.am
View file @
cc557bae
...
...
@@ -34,7 +34,7 @@ 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
6
_int_unittest.cc
libdhcp___unittests_SOURCES
+=
option_int_unittest.cc
libdhcp___unittests_SOURCES
+=
option_data_types_unittest.cc
libdhcp___unittests_SOURCES
+=
option_definition_unittest.cc
libdhcp___unittests_SOURCES
+=
option_custom_unittest.cc
...
...
src/lib/dhcp/tests/libdhcp++_unittest.cc
View file @
cc557bae
...
...
@@ -20,8 +20,8 @@
#include
<dhcp/option6_addrlst.h>
#include
<dhcp/option6_ia.h>
#include
<dhcp/option6_iaaddr.h>
#include
<dhcp/option6_int.h>
#include
<dhcp/option6_int_array.h>
#include
<dhcp/option_int.h>
#include
<dhcp/option_custom.h>
#include
<util/buffer.h>
...
...
@@ -314,8 +314,8 @@ TEST_F(LibDhcpTest, unpackOptions6) {
// Option with code 8 is OPTION_ELAPSED_TIME. This option is
// represented by Option6Int<uint16_t> value that holds single
// uint16_t value.
boost
::
shared_ptr
<
Option
6
Int
<
uint16_t
>
>
opt_elapsed_time
=
boost
::
dynamic_pointer_cast
<
Option
6
Int
<
uint16_t
>
>
(
x
->
second
);
boost
::
shared_ptr
<
OptionInt
<
uint16_t
>
>
opt_elapsed_time
=
boost
::
dynamic_pointer_cast
<
OptionInt
<
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_elapsed_time
);
...
...
@@ -627,7 +627,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
LibDhcpTest
::
testStdOptionDefs6
(
D6O_IA_NA
,
buf
,
typeid
(
Option6IA
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_IA_TA
,
buf
,
typeid
(
Option
6
Int
<
uint32_t
>
));
typeid
(
OptionInt
<
uint32_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_IAADDR
,
buf
,
typeid
(
Option6IAAddr
));
...
...
@@ -635,10 +635,10 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
typeid
(
Option6IntArray
<
uint16_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_PREFERENCE
,
buf
,
typeid
(
Option
6
Int
<
uint8_t
>
));
typeid
(
OptionInt
<
uint8_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_ELAPSED_TIME
,
buf
,
typeid
(
Option
6
Int
<
uint16_t
>
));
typeid
(
OptionInt
<
uint16_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_RELAY_MSG
,
buf
,
typeid
(
Option
));
...
...
@@ -656,7 +656,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
LibDhcpTest
::
testStdOptionDefs6
(
D6O_INTERFACE_ID
,
buf
,
typeid
(
Option
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_RECONF_MSG
,
buf
,
typeid
(
Option
6
Int
<
uint8_t
>
));
typeid
(
OptionInt
<
uint8_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_RECONF_ACCEPT
,
buf
,
typeid
(
Option
));
...
...
@@ -692,7 +692,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
typeid
(
Option6AddrLst
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_INFORMATION_REFRESH_TIME
,
buf
,
typeid
(
Option
6
Int
<
uint32_t
>
));
buf
,
typeid
(
OptionInt
<
uint32_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_BCMCS_SERVER_D
,
fqdn_buf
,
typeid
(
OptionCustom
));
...
...
@@ -730,7 +730,7 @@ TEST_F(LibDhcpTest, stdOptionDefs6) {
LibDhcpTest
::
testStdOptionDefs6
(
D6O_CLIENT_DATA
,
buf
,
typeid
(
Option
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_CLT_TIME
,
buf
,
typeid
(
Option
6
Int
<
uint32_t
>
));
typeid
(
OptionInt
<
uint32_t
>
));
LibDhcpTest
::
testStdOptionDefs6
(
D6O_LQ_RELAY_DATA
,
buf
,
typeid
(
OptionCustom
));
...
...
src/lib/dhcp/tests/option_definition_unittest.cc
View file @
cc557bae
...
...
@@ -21,10 +21,10 @@
#include
<dhcp/option6_addrlst.h>
#include
<dhcp/option6_ia.h>
#include
<dhcp/option6_iaaddr.h>
#include
<dhcp/option6_int.h>
#include
<dhcp/option6_int_array.h>
#include
<dhcp/option_custom.h>
#include
<dhcp/option_definition.h>
#include
<dhcp/option_int.h>
#include
<exceptions/exceptions.h>
#include
<boost/pointer_cast.hpp>
...
...
@@ -578,10 +578,10 @@ TEST_F(OptionDefinitionTest, uint8) {
ASSERT_NO_THROW
(
option_v6
=
opt_def
.
optionFactory
(
Option
::
V6
,
D6O_PREFERENCE
,
OptionBuffer
(
1
,
1
));
);
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
Option
6
Int
<
uint8_t
>
));
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
OptionInt
<
uint8_t
>
));
// Validate the value.
boost
::
shared_ptr
<
Option
6
Int
<
uint8_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
Option
6
Int
<
uint8_t
>
>
(
option_v6
);
boost
::
shared_ptr
<
OptionInt
<
uint8_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
OptionInt
<
uint8_t
>
>
(
option_v6
);
EXPECT_EQ
(
1
,
option_cast_v6
->
getValue
());
// Try to provide zero-length buffer. Expect exception.
...
...
@@ -606,10 +606,10 @@ TEST_F(OptionDefinitionTest, uint8Tokenized) {
ASSERT_NO_THROW
(
option_v6
=
opt_def
.
optionFactory
(
Option
::
V6
,
D6O_PREFERENCE
,
values
);
);
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
Option
6
Int
<
uint8_t
>
));
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
OptionInt
<
uint8_t
>
));
// Validate the value.
boost
::
shared_ptr
<
Option
6
Int
<
uint8_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
Option
6
Int
<
uint8_t
>
>
(
option_v6
);
boost
::
shared_ptr
<
OptionInt
<
uint8_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
OptionInt
<
uint8_t
>
>
(
option_v6
);
EXPECT_EQ
(
123
,
option_cast_v6
->
getValue
());
// @todo Add more cases for DHCPv4
...
...
@@ -629,10 +629,10 @@ TEST_F(OptionDefinitionTest, uint16) {
ASSERT_NO_THROW
(
option_v6
=
opt_def
.
optionFactory
(
Option
::
V6
,
D6O_ELAPSED_TIME
,
buf
);
);
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
Option
6
Int
<
uint16_t
>
));
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
OptionInt
<
uint16_t
>
));
// Validate the value.
boost
::
shared_ptr
<
Option
6
Int
<
uint16_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
Option
6
Int
<
uint16_t
>
>
(
option_v6
);
boost
::
shared_ptr
<
OptionInt
<
uint16_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
OptionInt
<
uint16_t
>
>
(
option_v6
);
EXPECT_EQ
(
0x0102
,
option_cast_v6
->
getValue
());
// Try to provide zero-length buffer. Expect exception.
...
...
@@ -658,10 +658,10 @@ TEST_F(OptionDefinitionTest, uint16Tokenized) {
ASSERT_NO_THROW
(
option_v6
=
opt_def
.
optionFactory
(
Option
::
V6
,
D6O_ELAPSED_TIME
,
values
);
);
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
Option
6
Int
<
uint16_t
>
));
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
OptionInt
<
uint16_t
>
));
// Validate the value.
boost
::
shared_ptr
<
Option
6
Int
<
uint16_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
Option
6
Int
<
uint16_t
>
>
(
option_v6
);
boost
::
shared_ptr
<
OptionInt
<
uint16_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
OptionInt
<
uint16_t
>
>
(
option_v6
);
EXPECT_EQ
(
1234
,
option_cast_v6
->
getValue
());
// @todo Add more cases for DHCPv4
...
...
@@ -683,10 +683,10 @@ TEST_F(OptionDefinitionTest, uint32) {
ASSERT_NO_THROW
(
option_v6
=
opt_def
.
optionFactory
(
Option
::
V6
,
D6O_CLT_TIME
,
buf
);
);
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
Option
6
Int
<
uint32_t
>
));
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
OptionInt
<
uint32_t
>
));
// Validate the value.
boost
::
shared_ptr
<
Option
6
Int
<
uint32_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
Option
6
Int
<
uint32_t
>
>
(
option_v6
);
boost
::
shared_ptr
<
OptionInt
<
uint32_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
OptionInt
<
uint32_t
>
>
(
option_v6
);
EXPECT_EQ
(
0x01020304
,
option_cast_v6
->
getValue
());
// Try to provide too short buffer. Expect exception.
...
...
@@ -711,10 +711,10 @@ TEST_F(OptionDefinitionTest, uint32Tokenized) {
ASSERT_NO_THROW
(
option_v6
=
opt_def
.
optionFactory
(
Option
::
V6
,
D6O_CLT_TIME
,
values
);
);
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
Option
6
Int
<
uint32_t
>
));
ASSERT_TRUE
(
typeid
(
*
option_v6
)
==
typeid
(
OptionInt
<
uint32_t
>
));
// Validate the value.
boost
::
shared_ptr
<
Option
6
Int
<
uint32_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
Option
6
Int
<
uint32_t
>
>
(
option_v6
);
boost
::
shared_ptr
<
OptionInt
<
uint32_t
>
>
option_cast_v6
=
boost
::
static_pointer_cast
<
OptionInt
<
uint32_t
>
>
(
option_v6
);
EXPECT_EQ
(
123456
,
option_cast_v6
->
getValue
());
// @todo Add more cases for DHCPv4
...
...
src/lib/dhcp/tests/option
6
_int_unittest.cc
→
src/lib/dhcp/tests/option_int_unittest.cc
View file @
cc557bae
...
...
@@ -17,7 +17,7 @@
#include
<dhcp/dhcp6.h>
#include
<dhcp/option.h>
#include
<dhcp/option6_iaaddr.h>
#include
<dhcp/option
6
_int.h>
#include
<dhcp/option_int.h>
#include
<util/buffer.h>
#include
<boost/pointer_cast.hpp>
...
...
@@ -31,13 +31,13 @@ using namespace isc::util;
namespace
{
/// @brief Option
6
Int test class.
class
Option
6
IntTest
:
public
::
testing
::
Test
{
/// @brief OptionInt test class.
class
OptionIntTest
:
public
::
testing
::
Test
{
public:
/// @brief Constructor.
///
/// Initializes the option buffer with some data.
Option
6
IntTest
()
:
buf_
(
255
),
out_buf_
(
255
)
{
OptionIntTest
()
:
buf_
(
255
),
out_buf_
(
255
)
{
for
(
int
i
=
0
;
i
<
255
;
i
++
)
{
buf_
[
i
]
=
255
-
i
;
}
...
...
@@ -52,12 +52,12 @@ public:
template
<
typename
T
>
void
basicTest8
()
{
// Create option that conveys single 8 bit integer value.
boost
::
shared_ptr
<
Option
6
Int
<
T
>
>
opt
;
boost
::
shared_ptr
<
OptionInt
<
T
>
>
opt
;
// Initialize buffer with this value.
buf_
[
0
]
=
0xa1
;
// Constructor may throw in case provided buffer is too short.
ASSERT_NO_THROW
(
opt
=
boost
::
shared_ptr
<
Option
6
Int
<
T
>
>
(
new
Option
6
Int
<
T
>
(
D6O_PREFERENCE
,
opt
=
boost
::
shared_ptr
<
OptionInt
<
T
>
>
(
new
OptionInt
<
T
>
(
D6O_PREFERENCE
,
buf_
.
begin
(),
buf_
.
end
()))
);
...
...
@@ -96,13 +96,13 @@ public:
template
<
typename
T
>
void
basicTest16
()
{
// Create option that conveys single 16-bit integer value.
boost
::
shared_ptr
<
Option
6
Int
<
T
>
>
opt
;
boost
::
shared_ptr
<
OptionInt
<
T
>
>
opt
;
// Initialize buffer with uint16_t value.
buf_
[
0
]
=
0xa1
;
buf_
[
1
]
=
0xa2
;
// Constructor may throw in case provided buffer is too short.
ASSERT_NO_THROW
(
opt
=
boost
::
shared_ptr
<
Option
6
Int
<
T
>
>
(
new
Option
6
Int
<
T
>
(
D6O_ELAPSED_TIME
,
opt
=
boost
::
shared_ptr
<
OptionInt
<
T
>
>
(
new
OptionInt
<
T
>
(
D6O_ELAPSED_TIME
,
buf_
.
begin
(),
buf_
.
end
()))
);
...
...
@@ -141,7 +141,7 @@ public:
template
<
typename
T
>
void
basicTest32
()
{
// Create option that conveys single 32-bit integer value.
boost
::
shared_ptr
<
Option
6
Int
<
T
>
>
opt
;
boost
::
shared_ptr
<
OptionInt
<
T
>
>
opt
;
// Initialize buffer with 32-bit integer value.
buf_
[
0
]
=
0xa1
;
buf_
[
1
]
=
0xa2
;
...
...
@@ -149,7 +149,7 @@ public:
buf_
[
3
]
=
0xa4
;
// Constructor may throw in case provided buffer is too short.
ASSERT_NO_THROW
(
opt
=
boost
::
shared_ptr
<
Option
6
Int
<
T
>
>
(
new
Option
6
Int
<
T
>
(
D6O_CLT_TIME
,
opt
=
boost
::
shared_ptr
<
OptionInt
<
T
>
>
(
new
OptionInt
<
T
>
(
D6O_CLT_TIME
,
buf_
.
begin
(),
buf_
.
end
()))
);
...
...
@@ -187,45 +187,45 @@ public:
/// convey unsigned value. We should maybe extend these tests for
/// signed types too.
TEST_F
(
Option
6
IntTest
,
useInvalidType
)
{
TEST_F
(
OptionIntTest
,
useInvalidType
)
{
EXPECT_THROW
(
boost
::
scoped_ptr
<
Option
6
Int
<
bool
>
>
(
new
Option
6
Int
<
bool
>
(
D6O_ELAPSED_TIME
,
10
)),
boost
::
scoped_ptr
<
OptionInt
<
bool
>
>
(
new
OptionInt
<
bool
>
(
D6O_ELAPSED_TIME
,
10
)),
InvalidDataType
);
EXPECT_THROW
(
boost
::
scoped_ptr
<
Option
6
Int
<
int64_t
>
>
(
new
Option
6
Int
<
int64_t
>
(
D6O_ELAPSED_TIME
,
10
)),
boost
::
scoped_ptr
<
OptionInt
<
int64_t
>
>
(
new
OptionInt
<
int64_t
>
(
D6O_ELAPSED_TIME
,
10
)),
InvalidDataType
);
}
TEST_F
(
Option
6
IntTest
,
basicUint8
)
{
TEST_F
(
OptionIntTest
,
basicUint8
)
{
basicTest8
<
uint8_t
>
();
}
TEST_F
(
Option
6
IntTest
,
basicUint16
)
{
TEST_F
(
OptionIntTest
,
basicUint16
)
{
basicTest16
<
uint16_t
>
();
}
TEST_F
(
Option
6
IntTest
,
basicUint32
)
{
TEST_F
(
OptionIntTest
,
basicUint32
)
{
basicTest32
<
uint32_t
>
();
}
TEST_F
(
Option
6
IntTest
,
basicInt8
)
{
TEST_F
(
OptionIntTest
,
basicInt8
)
{
basicTest8
<
int8_t
>
();
}
TEST_F
(
Option
6
IntTest
,
basicInt16
)
{
TEST_F
(
OptionIntTest
,
basicInt16
)
{
basicTest16
<
int16_t
>
();
}
TEST_F
(
Option
6
IntTest
,
basicInt32
)
{
TEST_F
(
OptionIntTest
,
basicInt32
)
{
basicTest32
<
int32_t
>
();
}
TEST_F
(
Option
6
IntTest
,
setValueUint8
)
{
boost
::
shared_ptr
<
Option
6
Int
<
uint8_t
>
>
opt
(
new
Option
6
Int
<
uint8_t
>
(
D6O_PREFERENCE
,
123
));
TEST_F
(
OptionIntTest
,
setValueUint8
)
{
boost
::
shared_ptr
<
OptionInt
<
uint8_t
>
>
opt
(
new
OptionInt
<
uint8_t
>
(
D6O_PREFERENCE
,
123
));
// Check if constructor intitialized the option value correctly.
EXPECT_EQ
(
123
,
opt
->
getValue
());
// Override the value.
...
...
@@ -237,8 +237,8 @@ TEST_F(Option6IntTest, setValueUint8) {
EXPECT_EQ
(
111
,
opt
->
getValue
());
}
TEST_F
(
Option
6
IntTest
,
setValueInt8
)
{
boost
::
shared_ptr
<
Option
6
Int
<
int8_t
>
>
opt
(
new
Option
6
Int
<
int8_t
>
(
D6O_PREFERENCE
,
-
123
));
TEST_F
(
OptionIntTest
,
setValueInt8
)
{
boost
::
shared_ptr
<
OptionInt
<
int8_t
>
>
opt
(
new
OptionInt
<
int8_t
>
(
D6O_PREFERENCE
,
-
123
));
// Check if constructor intitialized the option value correctly.
EXPECT_EQ
(
-
123
,
opt
->
getValue
());
// Override the value.
...
...
@@ -251,8 +251,8 @@ TEST_F(Option6IntTest, setValueInt8) {
}
TEST_F
(
Option
6
IntTest
,
setValueUint16
)
{
boost
::
shared_ptr
<
Option
6
Int
<
uint16_t
>
>
opt
(
new
Option
6
Int
<
uint16_t
>
(
D6O_ELAPSED_TIME
,
123
));
TEST_F
(
OptionIntTest
,
setValueUint16
)
{
boost
::
shared_ptr
<
OptionInt
<
uint16_t
>
>
opt
(
new
OptionInt
<
uint16_t
>
(
D6O_ELAPSED_TIME
,
123
));
// Check if constructor intitialized the option value correctly.
EXPECT_EQ
(
123
,
opt
->
getValue
());
// Override the value.
...
...
@@ -264,8 +264,8 @@ TEST_F(Option6IntTest, setValueUint16) {
EXPECT_EQ
(
0x0102
,
opt
->
getValue
());
}
TEST_F
(
Option
6
IntTest
,
setValueInt16
)
{
boost
::
shared_ptr
<
Option
6
Int
<
int16_t
>
>
opt
(
new
Option
6
Int
<
int16_t
>
(
D6O_ELAPSED_TIME
,
-
16500
));
TEST_F
(
OptionIntTest
,
setValueInt16
)
{
boost
::
shared_ptr
<
OptionInt
<
int16_t
>
>
opt
(
new
OptionInt
<
int16_t
>
(
D6O_ELAPSED_TIME
,
-
16500
));
// Check if constructor intitialized the option value correctly.
EXPECT_EQ
(
-
16500
,
opt
->
getValue
());
// Override the value.
...
...
@@ -277,8 +277,8 @@ TEST_F(Option6IntTest, setValueInt16) {
EXPECT_EQ
(
-
20100
,
opt
->
getValue
());
}
TEST_F
(
Option
6
IntTest
,
setValueUint32
)
{
boost
::
shared_ptr
<
Option
6
Int
<
uint32_t
>
>
opt
(
new
Option
6
Int
<
uint32_t
>
(
D6O_CLT_TIME
,
123
));
TEST_F
(
OptionIntTest
,
setValueUint32
)
{
boost
::
shared_ptr
<
OptionInt
<
uint32_t
>
>
opt
(
new
OptionInt
<
uint32_t
>
(
D6O_CLT_TIME
,
123
));
// Check if constructor intitialized the option value correctly.
EXPECT_EQ
(
123
,
opt
->
getValue
());
// Override the value.
...
...
@@ -290,8 +290,8 @@ TEST_F(Option6IntTest, setValueUint32) {
EXPECT_EQ
(
0x01020304
,
opt
->
getValue
());
}
TEST_F
(
Option
6
IntTest
,
setValueint32
)
{
boost
::
shared_ptr
<
Option
6
Int
<
int32_t
>
>
opt
(
new
Option
6
Int
<
int32_t
>
(
D6O_CLT_TIME
,
-
120100
));
TEST_F
(
OptionIntTest
,
setValueint32
)
{
boost
::
shared_ptr
<
OptionInt
<
int32_t
>
>
opt
(
new
OptionInt
<
int32_t
>
(
D6O_CLT_TIME
,
-
120100
));
// Check if constructor intitialized the option value correctly.
EXPECT_EQ
(
-
120100
,
opt
->
getValue
());
// Override the value.
...
...
@@ -303,12 +303,12 @@ TEST_F(Option6IntTest, setValueint32) {
EXPECT_EQ
(
-
125000
,
opt
->
getValue
());
}
TEST_F
(
Option
6
IntTest
,
packSuboptions
)
{
TEST_F
(
OptionIntTest
,
packSuboptions
)
{
// option code is really uint16_t, but using uint8_t
// for easier conversion to uint8_t array.
uint8_t
opt_code
=
80
;
boost
::
shared_ptr
<
Option
6
Int
<
uint32_t
>
>
opt
(
new
Option
6
Int
<
uint32_t
>
(
opt_code
,
0x01020304
));
boost
::
shared_ptr
<
OptionInt
<
uint32_t
>
>
opt
(
new
OptionInt
<
uint32_t
>
(
opt_code
,
0x01020304
));
OptionPtr
sub1
(
new
Option
(
Option
::
V6
,
0xcafe
));
boost
::
shared_ptr
<
Option6IAAddr
>
addr1
(
...
...
@@ -347,7 +347,7 @@ TEST_F(Option6IntTest, packSuboptions) {
}
TEST_F
(
Option
6
IntTest
,
unpackSuboptions
)
{
TEST_F
(
OptionIntTest
,
unpackSuboptions
)
{
// option code is really uint16_t, but using uint8_t
// for easier conversion to uint8_t array.
const
uint8_t
opt_code
=
80
;
...
...
@@ -373,10 +373,10 @@ TEST_F(Option6IntTest, unpackSuboptions) {
memcpy
(
&
buf_
[
0
],
expected
,
sizeof
(
expected
));
boost
::
shared_ptr
<
Option
6
Int
<
uint16_t
>
>
opt
;
boost
::
shared_ptr
<
OptionInt
<
uint16_t
>
>
opt
;
EXPECT_NO_THROW
(
opt
=
boost
::
shared_ptr
<
Option
6
Int
<
uint16_t
>
>
(
new
Option
6
Int
<
uint16_t
>
(
opt_code
,
buf_
.
begin
()
+
4
,
OptionInt
<
uint16_t
>
>
(
new
OptionInt
<
uint16_t
>
(
opt_code
,
buf_
.
begin
()
+
4
,
buf_
.
begin
()
+
sizeof
(
expected
)));
);
ASSERT_TRUE
(
opt
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment