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
ISC Open Source Projects
Kea
Commits
1328552a
Commit
1328552a
authored
Sep 01, 2017
by
Marcin Siodelski
Browse files
[5305] Added unit test for shared network destruction.
parent
c98545fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/tests/shared_network_unittest.cc
View file @
1328552a
...
...
@@ -245,6 +245,32 @@ TEST(SharedNetwork4Test, unparse) {
test
::
runToElementTest
<
SharedNetwork4
>
(
expected
,
*
network
);
}
// This test verifies that when the shared network object is destroyed,
// the subnets belonging to this shared network will not hold the pointer
// to the destroyed network.
TEST
(
SharedNetwork4Test
,
destructSharedNetwork
)
{
// Create a network and add a subnet to it.
SharedNetwork4Ptr
network
(
new
SharedNetwork4
(
"frog"
));
Subnet4Ptr
subnet
(
new
Subnet4
(
IOAddress
(
"10.0.0.0"
),
8
,
10
,
20
,
30
,
SubnetID
(
1
)));
ASSERT_NO_THROW
(
network
->
add
(
subnet
));
// Get the pointer to the network from subnet.
SharedNetwork4Ptr
subnet_to_network
;
subnet
->
getSharedNetwork
(
subnet_to_network
);
ASSERT_TRUE
(
subnet_to_network
);
// Reset the pointer to not hold the reference to the shared network.
subnet_to_network
.
reset
();
// Destroy the network object.
network
.
reset
();
// The reference to the network from the subnet should be lost.
subnet
->
getSharedNetwork
(
subnet_to_network
);
ASSERT_FALSE
(
subnet_to_network
);
}
// This test verifies that shared network can be given a name and that
// this name can be retrieved.
TEST
(
SharedNetwork6Test
,
getName
)
{
...
...
@@ -462,4 +488,31 @@ TEST(SharedNetwork6Test, unparse) {
test
::
runToElementTest
<
SharedNetwork6
>
(
expected
,
*
network
);
}
// This test verifies that when the shared network object is destroyed,
// the subnets belonging to this shared network will not hold the pointer
// to the destroyed network.
TEST
(
SharedNetwork6Test
,
destructSharedNetwork
)
{
// Create a network and add a subnet to it.
SharedNetwork6Ptr
network
(
new
SharedNetwork6
(
"frog"
));
Subnet6Ptr
subnet
(
new
Subnet6
(
IOAddress
(
"2001:db8:1::"
),
64
,
10
,
20
,
30
,
40
,
SubnetID
(
1
)));
ASSERT_NO_THROW
(
network
->
add
(
subnet
));
// Get the pointer to the network from subnet.
SharedNetwork6Ptr
subnet_to_network
;
subnet
->
getSharedNetwork
(
subnet_to_network
);
ASSERT_TRUE
(
subnet_to_network
);
// Reset the pointer to not hold the reference to the shared network.
subnet_to_network
.
reset
();
// Destroy the network object.
network
.
reset
();
// The reference to the network from the subnet should be lost.
subnet
->
getSharedNetwork
(
subnet_to_network
);
ASSERT_FALSE
(
subnet_to_network
);
}
}
// end of anonymous namespace
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