Commit 36d3b727 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2053] Add operator<< to dns::LabelSequence

parent 0bebde9e
......@@ -117,5 +117,11 @@ LabelSequence::toText() const {
return (name_.toText(!isAbsolute(), first_label_, last_label_));
}
std::ostream&
operator<<(std::ostream& os, const LabelSequence& label_sequence) {
os << label_sequence.toText();
return (os);
}
} // end namespace dns
} // end namespace isc
......@@ -187,6 +187,23 @@ private:
};
///
/// \brief Insert the label sequence as a string into stream.
///
/// This method convert the \c label_sequence into a string and inserts
/// it into the output stream \c os.
///
/// This function overloads the global operator<< to behave as described in
/// ostream::operator<< but applied to \c LabelSequence objects.
///
/// \param os A \c std::ostream object on which the insertion operation is
/// performed.
/// \param name The \c LabelSequence object output by the operation.
/// \return A reference to the same \c std::ostream object referenced by
/// parameter \c os after the insertion operation.
std::ostream&
operator<<(std::ostream& os, const LabelSequence& label_sequence);
} // end namespace dns
} // end namespace isc
......
......@@ -394,4 +394,10 @@ TEST_F(LabelSequenceTest, getHash) {
hashDistributionCheck(ca_servers);
}
// test operator<<. We simply confirm it appends the result of toText().
TEST_F(LabelSequenceTest, LeftShiftOperator) {
ostringstream oss;
oss << ls1;
EXPECT_EQ(ls1.toText(), oss.str());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment