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
7286499d
Commit
7286499d
authored
Jan 14, 2014
by
Mukund Sivaraman
Browse files
Merge branch 'trac571'
parents
c243f842
9d6d5822
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/message.cc
View file @
7286499d
...
...
@@ -869,8 +869,11 @@ struct SectionFormatter {
void
operator
()(
const
T
&
entry
)
{
if
(
section_
==
Message
::
SECTION_QUESTION
)
{
output_
+=
";"
;
output_
+=
entry
->
toText
();
output_
+=
"
\n
"
;
}
else
{
output_
+=
entry
->
toText
();
}
output_
+=
entry
->
toText
();
}
const
Message
::
Section
section_
;
string
&
output_
;
...
...
src/lib/dns/python/tests/question_python_test.py
View file @
7286499d
...
...
@@ -70,9 +70,9 @@ class QuestionTest(unittest.TestCase):
def
test_to_text
(
self
):
self
.
assertEqual
(
"foo.example.com. IN NS
\n
"
,
self
.
test_question1
.
to_text
())
self
.
assertEqual
(
"foo.example.com. IN NS
\n
"
,
str
(
self
.
test_question1
))
self
.
assertEqual
(
"bar.example.com. CH A
\n
"
,
self
.
test_question2
.
to_text
())
self
.
assertEqual
(
"foo.example.com. IN NS"
,
self
.
test_question1
.
to_text
())
self
.
assertEqual
(
"foo.example.com. IN NS"
,
str
(
self
.
test_question1
))
self
.
assertEqual
(
"bar.example.com. CH A"
,
self
.
test_question2
.
to_text
())
def
test_to_wire_buffer
(
self
):
obuffer
=
bytes
()
...
...
src/lib/dns/question.cc
View file @
7286499d
...
...
@@ -40,10 +40,15 @@ Question::Question(InputBuffer& buffer) :
rrclass_
=
RRClass
(
buffer
);
}
string
Question
::
toText
()
const
{
return
(
name_
.
toText
()
+
" "
+
rrclass_
.
toText
()
+
" "
+
rrtype_
.
toText
()
+
"
\n
"
);
std
::
string
Question
::
toText
(
bool
newline
)
const
{
std
::
string
r
(
name_
.
toText
()
+
" "
+
rrclass_
.
toText
()
+
" "
+
rrtype_
.
toText
());
if
(
newline
)
{
r
.
append
(
"
\n
"
);
}
return
(
r
);
}
unsigned
int
...
...
src/lib/dns/question.h
View file @
7286499d
...
...
@@ -173,9 +173,9 @@ public:
//@{
/// \brief Convert the Question to a string.
///
///
Un
li
k
e
other similar methods of this library
, this method terminates
///
the
resulting string with a trailing newline character
///
(following
the BIND9 convention).
///
When \c new
li
n
e
argument is \c true
, this method terminates
the
/// resulting string with a trailing newline character
(following
/// the BIND9 convention).
///
/// This method simply calls the \c %toText() methods of the corresponding
/// \c Name, \c RRType and \c RRClass classes for this \c Question, and
...
...
@@ -183,8 +183,12 @@ public:
/// In particular, if resource allocation fails, a corresponding standard
/// exception will be thrown.
///
/// \param newline Whether to add a trailing newline. If true, a
/// trailing newline is added. If false, no trailing newline is
/// added.
///
/// \return A string representation of the \c Question.
std
::
string
toText
()
const
;
std
::
string
toText
(
bool
newline
=
false
)
const
;
/// \brief Render the Question in the wire format with name compression.
///
...
...
src/lib/dns/tests/question_unittest.cc
View file @
7286499d
...
...
@@ -86,8 +86,14 @@ TEST_F(QuestionTest, fromWire) {
}
TEST_F
(
QuestionTest
,
toText
)
{
EXPECT_EQ
(
"foo.example.com. IN NS
\n
"
,
test_question1
.
toText
());
EXPECT_EQ
(
"bar.example.com. CH A
\n
"
,
test_question2
.
toText
());
EXPECT_EQ
(
"foo.example.com. IN NS"
,
test_question1
.
toText
());
EXPECT_EQ
(
"bar.example.com. CH A"
,
test_question2
.
toText
());
EXPECT_EQ
(
"foo.example.com. IN NS"
,
test_question1
.
toText
(
false
));
EXPECT_EQ
(
"bar.example.com. CH A"
,
test_question2
.
toText
(
false
));
EXPECT_EQ
(
"foo.example.com. IN NS
\n
"
,
test_question1
.
toText
(
true
));
EXPECT_EQ
(
"bar.example.com. CH A
\n
"
,
test_question2
.
toText
(
true
));
}
TEST_F
(
QuestionTest
,
toWireBuffer
)
{
...
...
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