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
94d72340
Commit
94d72340
authored
Jul 30, 2012
by
Jelte Jansen
Browse files
[2093] add RBNode<T>::getAbsoluteLabelSequence()
parent
c0f1785c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/rbtree.h
View file @
94d72340
...
...
@@ -221,6 +221,10 @@ public:
return
(
dns
::
LabelSequence
(
getLabelsData
()));
}
///
isc
::
dns
::
LabelSequence
getAbsoluteLabelSequence
(
uint8_t
buf
[
isc
::
dns
::
LabelSequence
::
MAX_SERIALIZED_LENGTH
])
const
;
/// \brief Return the data stored in this node.
///
/// You should not delete the data, it is handled by shared pointers.
...
...
@@ -502,6 +506,21 @@ RBNode<T>::getUpperNode() const {
return
(
current
->
getParent
());
}
template
<
typename
T
>
isc
::
dns
::
LabelSequence
RBNode
<
T
>::
getAbsoluteLabelSequence
(
uint8_t
buf
[
isc
::
dns
::
LabelSequence
::
MAX_SERIALIZED_LENGTH
])
const
{
isc
::
dns
::
LabelSequence
result
(
getLabels
(),
buf
);
const
RBNode
<
T
>*
upper
=
getUpperNode
();
while
(
upper
!=
NULL
)
{
result
.
extend
(
upper
->
getLabels
(),
buf
);
upper
=
upper
->
getUpperNode
();
}
return
(
isc
::
dns
::
LabelSequence
(
result
));
}
template
<
typename
T
>
const
RBNode
<
T
>*
RBNode
<
T
>::
abstractSuccessor
(
typename
RBNode
<
T
>::
RBNodePtr
RBNode
<
T
>::*
left
,
...
...
src/lib/datasrc/tests/rbtree_unittest.cc
View file @
94d72340
...
...
@@ -988,4 +988,32 @@ TEST_F(RBTreeTest, root) {
root
.
find
(
Name
(
"example.com"
),
&
crbtnode
));
EXPECT_EQ
(
rbtnode
,
crbtnode
);
}
TEST_F
(
RBTreeTest
,
getAbsoluteLabels
)
{
// The full absolute names of the nodes in the tree
const
char
*
const
domain_names
[]
=
{
"c"
,
"b"
,
"a"
,
"x.d.e.f"
,
"z.d.e.f"
,
"g.h"
,
"i.g.h"
,
"o.w.y.d.e.f"
,
"j.z.d.e.f"
,
"p.w.y.d.e.f"
,
"q.w.y.d.e.f"
,
"k.g.h"
};
// The names of the nodes themselves, as they end up in the tree
const
char
*
const
first_labels
[]
=
{
"c"
,
"b"
,
"a"
,
"x"
,
"z"
,
"g.h"
,
"i"
,
"o"
,
"j"
,
"p"
,
"q"
,
"k"
};
int
name_count
=
sizeof
(
domain_names
)
/
sizeof
(
domain_names
[
0
]);
uint8_t
buf
[
LabelSequence
::
MAX_SERIALIZED_LENGTH
];
for
(
int
i
=
0
;
i
<
name_count
;
++
i
)
{
EXPECT_EQ
(
RBTree
<
int
>::
EXACTMATCH
,
rbtree
.
find
(
Name
(
domain_names
[
i
]),
&
crbtnode
));
// First make sure the names themselves are not absolute
LabelSequence
ls
(
crbtnode
->
getLabels
());
EXPECT_EQ
(
first_labels
[
i
],
ls
.
toText
());
EXPECT_FALSE
(
ls
.
isAbsolute
());
// Now check the absolute names
LabelSequence
abs_ls
=
crbtnode
->
getAbsoluteLabelSequence
(
buf
);
EXPECT_EQ
(
Name
(
domain_names
[
i
]).
toText
(),
abs_ls
.
toText
());
EXPECT_TRUE
(
abs_ls
.
isAbsolute
());
}
}
}
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