Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
009d45df
Commit
009d45df
authored
Aug 04, 2011
by
Michal 'vorner' Vaner
Browse files
[trac1067] Tests for in-memory iteration
parent
f1d52ff7
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/client.h
View file @
009d45df
...
...
@@ -25,6 +25,7 @@
namespace
isc
{
namespace
datasrc
{
// The iterator.h is not included on purpose, most application won't need it
class
ZoneIterator
;
typedef
boost
::
shared_ptr
<
ZoneIterator
>
ZoneIteratorPtr
;
...
...
src/lib/datasrc/tests/memory_datasrc_unittest.cc
View file @
009d45df
...
...
@@ -29,6 +29,8 @@
#include <dns/masterload.h>
#include <datasrc/memory_datasrc.h>
#include <datasrc/data_source.h>
#include <datasrc/iterator.h>
#include <gtest/gtest.h>
...
...
@@ -138,6 +140,43 @@ TEST_F(InMemoryClientTest, add_find_Zone) {
getOrigin
());
}
TEST_F
(
InMemoryClientTest
,
iterator
)
{
// Just some preparations of data
boost
::
shared_ptr
<
InMemoryZoneFinder
>
zone
(
new
InMemoryZoneFinder
(
RRClass
::
IN
(),
Name
(
"a"
)));
RRsetPtr
aRRsetA
(
new
RRset
(
Name
(
"a"
),
RRClass
::
IN
(),
RRType
::
A
(),
RRTTL
(
300
)));
aRRsetA
->
addRdata
(
rdata
::
in
::
A
(
"192.0.2.1"
));
RRsetPtr
aRRsetAAAA
(
new
RRset
(
Name
(
"a"
),
RRClass
::
IN
(),
RRType
::
AAAA
(),
RRTTL
(
300
)));
aRRsetAAAA
->
addRdata
(
rdata
::
in
::
AAAA
(
"2001:db8::1"
));
aRRsetAAAA
->
addRdata
(
rdata
::
in
::
AAAA
(
"2001:db8::2"
));
RRsetPtr
subRRsetA
(
new
RRset
(
Name
(
"sub.x.a"
),
RRClass
::
IN
(),
RRType
::
A
(),
RRTTL
(
300
)));
subRRsetA
->
addRdata
(
rdata
::
in
::
A
(
"192.0.2.2"
));
EXPECT_EQ
(
result
::
SUCCESS
,
memory_client
.
addZone
(
ZoneFinderPtr
(
new
InMemoryZoneFinder
(
RRClass
::
IN
(),
Name
(
"a"
)))));
// First, the zone is not there, so it should throw
EXPECT_THROW
(
memory_client
.
getIterator
(
Name
(
"b"
)),
DataSourceError
);
// Now, an empty zone
ZoneIteratorPtr
iterator
(
memory_client
.
getIterator
(
Name
(
"a"
)));
EXPECT_EQ
(
ConstRRsetPtr
(),
iterator
->
getNextRRset
());
// It throws Unexpected when we are past the end
EXPECT_THROW
(
iterator
->
getNextRRset
(),
isc
::
Unexpected
);
EXPECT_EQ
(
result
::
SUCCESS
,
zone
->
add
(
aRRsetA
));
EXPECT_EQ
(
result
::
SUCCESS
,
zone
->
add
(
aRRsetAAAA
));
EXPECT_EQ
(
result
::
SUCCESS
,
zone
->
add
(
subRRsetA
));
// Check it with full zone, one by one.
// It should be in ascending order in case of InMemory data source
// (isn't guaranteed in general)
iterator
=
memory_client
.
getIterator
(
Name
(
"a"
));
EXPECT_EQ
(
aRRsetA
,
iterator
->
getNextRRset
());
EXPECT_EQ
(
aRRsetAAAA
,
iterator
->
getNextRRset
());
EXPECT_EQ
(
subRRsetA
,
iterator
->
getNextRRset
());
EXPECT_EQ
(
ConstRRsetPtr
(),
iterator
->
getNextRRset
());
}
TEST_F
(
InMemoryClientTest
,
getZoneCount
)
{
EXPECT_EQ
(
0
,
memory_client
.
getZoneCount
());
memory_client
.
addZone
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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