diff options
author | JINMEI Tatuya <jinmei@isc.org> | 2012-02-24 06:50:12 +0100 |
---|---|---|
committer | JINMEI Tatuya <jinmei@isc.org> | 2012-02-24 06:50:12 +0100 |
commit | fb9060e5dccc2bd43ede4da3e0fe0733aa9cc6fa (patch) | |
tree | 202965a609e88bae3e7f8a7297c332095f48d443 | |
parent | [1392] cleanup: removed a "short term" workaround in python/isc/log/Makefile.am (diff) | |
download | kea-fb9060e5dccc2bd43ede4da3e0fe0733aa9cc6fa.tar.xz kea-fb9060e5dccc2bd43ede4da3e0fe0733aa9cc6fa.zip |
[1697] 1st update: make MessageRenderer constructors parameter-free.
AbstractMessageRenderer now creates and holds its own buffer internally.
adjusted unittests and the python wrapper in a straightforward manner.
38 files changed, 114 insertions, 128 deletions
diff --git a/src/lib/dns/benchmarks/rdatarender_bench.cc b/src/lib/dns/benchmarks/rdatarender_bench.cc index d1fb0f27b7..368ea6a61d 100644 --- a/src/lib/dns/benchmarks/rdatarender_bench.cc +++ b/src/lib/dns/benchmarks/rdatarender_bench.cc @@ -42,7 +42,7 @@ template <typename T> class RdataRenderBenchMark { public: RdataRenderBenchMark(const vector<T>& dataset) : - dataset_(dataset), buffer_(4096), renderer_(buffer_) + dataset_(dataset) {} unsigned int run() { typename vector<T>::const_iterator data; @@ -55,7 +55,6 @@ public: } private: const vector<T>& dataset_; - OutputBuffer buffer_; MessageRenderer renderer_; }; diff --git a/src/lib/dns/messagerenderer.cc b/src/lib/dns/messagerenderer.cc index 1378ba9076..61418ce00b 100644 --- a/src/lib/dns/messagerenderer.cc +++ b/src/lib/dns/messagerenderer.cc @@ -171,8 +171,8 @@ struct MessageRenderer::MessageRendererImpl { CompressMode compress_mode_; }; -MessageRenderer::MessageRenderer(OutputBuffer& buffer) : - AbstractMessageRenderer(buffer), +MessageRenderer::MessageRenderer() : + AbstractMessageRenderer(), impl_(new MessageRendererImpl) {} @@ -273,9 +273,14 @@ MessageRenderer::writeName(const Name& name, const bool compress) { } } +AbstractMessageRenderer::AbstractMessageRenderer() : + local_buffer_(0), buffer_(&local_buffer_) +{ +} + void AbstractMessageRenderer::clear() { - buffer_.clear(); + buffer_->clear(); } } diff --git a/src/lib/dns/messagerenderer.h b/src/lib/dns/messagerenderer.h index 52d9245211..4673861674 100644 --- a/src/lib/dns/messagerenderer.h +++ b/src/lib/dns/messagerenderer.h @@ -102,29 +102,32 @@ protected: /// This is intentionally defined as \c protected as this base class should /// never be instantiated (except as part of a derived class). /// \param buffer The buffer where the data should be rendered into. + /// + /// We are now doing this: /// \todo We might want to revisit this API at some point and remove the /// buffer parameter. In that case it would create it's own buffer and /// a function to extract the data would be available instead. It seems /// like a cleaner design, but it's left undone until we would actually /// benefit from the change. - AbstractMessageRenderer(isc::util::OutputBuffer& buffer) : - buffer_(buffer) - {} + AbstractMessageRenderer(); public: /// \brief The destructor. virtual ~AbstractMessageRenderer() {} //@} protected: /// \brief Return the output buffer we render into. - const isc::util::OutputBuffer& getBuffer() const { return (buffer_); } - isc::util::OutputBuffer& getBuffer() { return (buffer_); } + const isc::util::OutputBuffer& getBuffer() const { return (*buffer_); } + isc::util::OutputBuffer& getBuffer() { return (*buffer_); } private: + /// \short Local (default) buffer to store data. + isc::util::OutputBuffer local_buffer_; + /// \short Buffer to store data /// /// It was decided that there's no need to have this in every subclass, /// at least not now, and this reduces code size and gives compiler a better /// chance to optimise. - isc::util::OutputBuffer& buffer_; + isc::util::OutputBuffer* buffer_; public: /// /// \name Getter Methods @@ -136,12 +139,12 @@ public: /// This method works exactly same as the same method of the \c OutputBuffer /// class; all notes for \c OutputBuffer apply. const void* getData() const { - return (buffer_.getData()); + return (buffer_->getData()); } /// \brief Return the length of data written in the internal buffer. size_t getLength() const { - return (buffer_.getLength()); + return (buffer_->getLength()); } /// \brief Return whether truncation has occurred while rendering. @@ -209,7 +212,7 @@ public: /// /// \param len The length of the gap to be inserted in bytes. void skip(size_t len) { - buffer_.skip(len); + buffer_->skip(len); } /// \brief Trim the specified length of data from the end of the internal @@ -223,7 +226,7 @@ public: /// /// \param len The length of data that should be trimmed. void trim(size_t len) { - buffer_.trim(len); + buffer_->trim(len); } /// \brief Clear the internal buffer and other internal resources. @@ -236,7 +239,7 @@ public: /// /// \param data The 8-bit integer to be written into the internal buffer. void writeUint8(const uint8_t data) { - buffer_.writeUint8(data); + buffer_->writeUint8(data); } /// \brief Write an unsigned 16-bit integer in host byte order into the @@ -244,7 +247,7 @@ public: /// /// \param data The 16-bit integer to be written into the buffer. void writeUint16(uint16_t data) { - buffer_.writeUint16(data); + buffer_->writeUint16(data); } /// \brief Write an unsigned 16-bit integer in host byte order at the @@ -259,7 +262,7 @@ public: /// \param data The 16-bit integer to be written into the internal buffer. /// \param pos The beginning position in the buffer to write the data. void writeUint16At(uint16_t data, size_t pos) { - buffer_.writeUint16At(data, pos); + buffer_->writeUint16At(data, pos); } /// \brief Write an unsigned 32-bit integer in host byte order into the @@ -267,7 +270,7 @@ public: /// /// \param data The 32-bit integer to be written into the buffer. void writeUint32(uint32_t data) { - buffer_.writeUint32(data); + buffer_->writeUint32(data); } /// \brief Copy an arbitrary length of data into the internal buffer @@ -278,7 +281,7 @@ public: /// \param data A pointer to the data to be copied into the internal buffer. /// \param len The length of the data in bytes. void writeData(const void *data, size_t len) { - buffer_.writeData(data, len); + buffer_->writeData(data, len); } /// \brief Write a \c Name object into the internal buffer in wire format, @@ -316,10 +319,7 @@ public: using AbstractMessageRenderer::CASE_SENSITIVE; /// \brief Constructor from an output buffer. - /// - /// \param buffer An \c OutputBuffer object to which wire format data is - /// written. - MessageRenderer(isc::util::OutputBuffer& buffer); + MessageRenderer(); virtual ~MessageRenderer(); virtual bool isTruncated() const; diff --git a/src/lib/dns/python/messagerenderer_python.cc b/src/lib/dns/python/messagerenderer_python.cc index bb896228b2..5561c12c34 100644 --- a/src/lib/dns/python/messagerenderer_python.cc +++ b/src/lib/dns/python/messagerenderer_python.cc @@ -36,7 +36,6 @@ namespace { class s_MessageRenderer : public PyObject { public: s_MessageRenderer(); - isc::util::OutputBuffer* outputbuffer; MessageRenderer* cppobj; }; @@ -78,17 +77,14 @@ PyMethodDef MessageRenderer_methods[] = { int MessageRenderer_init(s_MessageRenderer* self) { - self->outputbuffer = new OutputBuffer(4096); - self->cppobj = new MessageRenderer(*self->outputbuffer); + self->cppobj = new MessageRenderer; return (0); } void MessageRenderer_destroy(s_MessageRenderer* self) { delete self->cppobj; - delete self->outputbuffer; self->cppobj = NULL; - self->outputbuffer = NULL; Py_TYPE(self)->tp_free(self); } diff --git a/src/lib/dns/rdatafields.cc b/src/lib/dns/rdatafields.cc index af9ba2e886..94c9dbf41d 100644 --- a/src/lib/dns/rdatafields.cc +++ b/src/lib/dns/rdatafields.cc @@ -70,8 +70,7 @@ namespace { // it's hopefully an acceptable practice. class RdataFieldComposer : public AbstractMessageRenderer { public: - RdataFieldComposer(OutputBuffer& buffer) : - AbstractMessageRenderer(buffer), + RdataFieldComposer() : truncated_(false), length_limit_(65535), mode_(CASE_INSENSITIVE), last_data_pos_(0) {} @@ -128,8 +127,7 @@ public: } RdataFields::RdataFields(const Rdata& rdata) { - OutputBuffer buffer(0); - RdataFieldComposer field_composer(buffer); + RdataFieldComposer field_composer; rdata.toWire(field_composer); nfields_ = field_composer.getFields().size(); data_length_ = field_composer.getLength(); diff --git a/src/lib/dns/tests/edns_unittest.cc b/src/lib/dns/tests/edns_unittest.cc index 26cc01c343..de2d2447dd 100644 --- a/src/lib/dns/tests/edns_unittest.cc +++ b/src/lib/dns/tests/edns_unittest.cc @@ -43,9 +43,7 @@ const uint8_t EDNS::SUPPORTED_VERSION; namespace { class EDNSTest : public ::testing::Test { protected: - EDNSTest() : rrtype(RRType::OPT()), buffer(NULL, 0), obuffer(0), - renderer(obuffer), rcode(0) - { + EDNSTest() : rrtype(RRType::OPT()), buffer(NULL, 0), obuffer(0), rcode(0) { opt_rdata = ConstRdataPtr(new generic::OPT()); edns_base.setUDPSize(4096); } diff --git a/src/lib/dns/tests/message_unittest.cc b/src/lib/dns/tests/message_unittest.cc index c5bc7fd840..3be1436caa 100644 --- a/src/lib/dns/tests/message_unittest.cc +++ b/src/lib/dns/tests/message_unittest.cc @@ -79,7 +79,6 @@ namespace { class MessageTest : public ::testing::Test { protected: MessageTest() : test_name("test.example.com"), obuffer(0), - renderer(obuffer), message_parse(Message::PARSE), message_render(Message::RENDER), bogus_section(static_cast<Message::Section>( @@ -731,8 +730,8 @@ TEST_F(MessageTest, toWire) { message_render.toWire(renderer); vector<unsigned char> data; UnitTestUtil::readWireData("message_toWire1", data); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(), - obuffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageTest, toWireInParseMode) { @@ -961,9 +960,6 @@ TEST_F(MessageTest, toWireTSIGNoTruncation) { // rendering fail unexpectedly in the test that follows. class BadRenderer : public MessageRenderer { public: - BadRenderer(isc::util::OutputBuffer& buffer) : - MessageRenderer(buffer) - {} virtual void setLengthLimit(size_t len) { if (getLength() > 0) { MessageRenderer::setLengthLimit(getLength()); @@ -994,8 +990,7 @@ TEST_F(MessageTest, toWireTSIGLengthErrors) { InvalidParameter); // Trying to render a message with TSIG using a buggy renderer. - obuffer.clear(); - BadRenderer bad_renderer(obuffer); + BadRenderer bad_renderer; bad_renderer.setLengthLimit(512); message_render.clear(Message::RENDER); EXPECT_THROW(commonTSIGToWireCheck(message_render, bad_renderer, tsig_ctx, diff --git a/src/lib/dns/tests/messagerenderer_unittest.cc b/src/lib/dns/tests/messagerenderer_unittest.cc index fe790fe837..575b484a12 100644 --- a/src/lib/dns/tests/messagerenderer_unittest.cc +++ b/src/lib/dns/tests/messagerenderer_unittest.cc @@ -30,15 +30,13 @@ using isc::util::OutputBuffer; namespace { class MessageRendererTest : public ::testing::Test { protected: - MessageRendererTest() : expected_size(0), buffer(0), renderer(buffer) - { + MessageRendererTest() : expected_size(0) { data16 = (2 << 8) | 3; data32 = (4 << 24) | (5 << 16) | (6 << 8) | 7; } size_t expected_size; uint16_t data16; uint32_t data32; - OutputBuffer buffer; MessageRenderer renderer; std::vector<unsigned char> data; static const uint8_t testdata[5]; @@ -60,21 +58,22 @@ TEST_F(MessageRendererTest, writeName) { renderer.writeName(Name("a.example.com.")); renderer.writeName(Name("b.example.com.")); renderer.writeName(Name("a.example.org.")); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageRendererTest, writeNameInLargeBuffer) { size_t offset = 0x3fff; - buffer.skip(offset); + renderer.skip(offset); UnitTestUtil::readWireData("name_toWire2", data); renderer.writeName(Name("a.example.com.")); renderer.writeName(Name("a.example.com.")); renderer.writeName(Name("b.example.com.")); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t*>(buffer.getData()) + offset, - buffer.getLength() - offset, + static_cast<const uint8_t*>(renderer.getData()) + + offset, + renderer.getLength() - offset, &data[0], data.size()); } @@ -83,8 +82,8 @@ TEST_F(MessageRendererTest, writeNameWithUncompressed) { renderer.writeName(Name("a.example.com.")); renderer.writeName(Name("b.example.com."), false); renderer.writeName(Name("b.example.com.")); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageRendererTest, writeNamePointerChain) { @@ -92,8 +91,8 @@ TEST_F(MessageRendererTest, writeNamePointerChain) { renderer.writeName(Name("a.example.com.")); renderer.writeName(Name("b.example.com.")); renderer.writeName(Name("b.example.com.")); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageRendererTest, compressMode) { @@ -120,8 +119,8 @@ TEST_F(MessageRendererTest, writeNameCaseCompress) { // this should match the first name in terms of compression: renderer.writeName(Name("b.exAmple.CoM.")); renderer.writeName(Name("a.example.org.")); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageRendererTest, writeNameCaseSensitiveCompress) { @@ -132,8 +131,8 @@ TEST_F(MessageRendererTest, writeNameCaseSensitiveCompress) { renderer.writeName(Name("a.example.com.")); renderer.writeName(Name("b.eXample.com.")); renderer.writeName(Name("c.eXample.com.")); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageRendererTest, writeNameMixedCaseCompress) { @@ -147,8 +146,8 @@ TEST_F(MessageRendererTest, writeNameMixedCaseCompress) { // allowed in this API. renderer.setCompressMode(MessageRenderer::CASE_INSENSITIVE); renderer.writeName(Name("c.b.EXAMPLE.com.")); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(MessageRendererTest, writeRootName) { @@ -164,8 +163,8 @@ TEST_F(MessageRendererTest, writeRootName) { renderer.writeName(Name(".")); renderer.writeName(example_name); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t*>(buffer.getData()), - buffer.getLength(), + static_cast<const uint8_t*>(renderer.getData()), + renderer.getLength(), static_cast<const uint8_t*>(expected.getData()), expected.getLength()); } diff --git a/src/lib/dns/tests/name_unittest.cc b/src/lib/dns/tests/name_unittest.cc index 6434229dd9..5216c49bc2 100644 --- a/src/lib/dns/tests/name_unittest.cc +++ b/src/lib/dns/tests/name_unittest.cc @@ -357,13 +357,12 @@ TEST_F(NameTest, toWireBuffer) { // TEST_F(NameTest, toWireRenderer) { vector<unsigned char> data; - OutputBuffer buffer(0); - MessageRenderer renderer(buffer); + MessageRenderer renderer; UnitTestUtil::readWireData(string("01610376697803636f6d00"), data); Name("a.vix.com.").toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, &data[0], data.size(), - buffer.getData(), buffer.getLength()); + renderer.getData(), renderer.getLength()); } // @@ -524,8 +523,8 @@ TEST_F(NameTest, at) { example_name.toWire(buffer_expected); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - &data[0], data.size(), - buffer_expected.getData(), buffer_expected.getLength()); + &data[0], data.size(), buffer_expected.getData(), + buffer_expected.getLength()); // Out-of-range access: should trigger an exception. EXPECT_THROW(example_name.at(example_name.getLength()), OutOfRange); diff --git a/src/lib/dns/tests/question_unittest.cc b/src/lib/dns/tests/question_unittest.cc index 1d483f2591..54d0942de1 100644 --- a/src/lib/dns/tests/question_unittest.cc +++ b/src/lib/dns/tests/question_unittest.cc @@ -37,7 +37,7 @@ using namespace isc::util; namespace { class QuestionTest : public ::testing::Test { protected: - QuestionTest() : obuffer(0), renderer(obuffer), + QuestionTest() : obuffer(0), example_name1(Name("foo.example.com")), example_name2(Name("bar.example.com")), test_question1(example_name1, RRClass::IN(), @@ -102,8 +102,8 @@ TEST_F(QuestionTest, toWireRenderer) { test_question1.toWire(renderer); test_question2.toWire(renderer); UnitTestUtil::readWireData("question_toWire2", wiredata); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(), - obuffer.getLength(), &wiredata[0], wiredata.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &wiredata[0], wiredata.size()); } TEST_F(QuestionTest, toWireTruncated) { diff --git a/src/lib/dns/tests/rdata_afsdb_unittest.cc b/src/lib/dns/tests/rdata_afsdb_unittest.cc index 7df8d83659..521bec5d05 100644 --- a/src/lib/dns/tests/rdata_afsdb_unittest.cc +++ b/src/lib/dns/tests/rdata_afsdb_unittest.cc @@ -162,7 +162,7 @@ TEST_F(Rdata_AFSDB_Test, toWireRenderer) { renderer.clear(); // construct actual data - Name("example.com.").toWire(obuffer); + renderer.writeName(Name("example.com.")); rdata_afsdb2.toWire(renderer); // construct expected data diff --git a/src/lib/dns/tests/rdata_cname_unittest.cc b/src/lib/dns/tests/rdata_cname_unittest.cc index d6b02aa49b..2cce9bc849 100644 --- a/src/lib/dns/tests/rdata_cname_unittest.cc +++ b/src/lib/dns/tests/rdata_cname_unittest.cc @@ -97,11 +97,11 @@ TEST_F(Rdata_CNAME_Test, toWireBuffer) { TEST_F(Rdata_CNAME_Test, toWireRenderer) { rdata_cname.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_cname, sizeof(wiredata_cname)); rdata_cname2.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_cname2, sizeof(wiredata_cname2)); } diff --git a/src/lib/dns/tests/rdata_dname_unittest.cc b/src/lib/dns/tests/rdata_dname_unittest.cc index ebd9e0e04f..cf3001c876 100644 --- a/src/lib/dns/tests/rdata_dname_unittest.cc +++ b/src/lib/dns/tests/rdata_dname_unittest.cc @@ -97,11 +97,11 @@ TEST_F(Rdata_DNAME_Test, toWireBuffer) { TEST_F(Rdata_DNAME_Test, toWireRenderer) { rdata_dname.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_dname, sizeof(wiredata_dname)); rdata_dname2.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_dname2, sizeof(wiredata_dname2)); } diff --git a/src/lib/dns/tests/rdata_dnskey_unittest.cc b/src/lib/dns/tests/rdata_dnskey_unittest.cc index f0596ed989..86b8f69725 100644 --- a/src/lib/dns/tests/rdata_dnskey_unittest.cc +++ b/src/lib/dns/tests/rdata_dnskey_unittest.cc @@ -90,8 +90,8 @@ TEST_F(Rdata_DNSKEY_Test, toWireRenderer) { vector<unsigned char> data; UnitTestUtil::readWireData("rdata_dnskey_fromWire", data); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t *>(obuffer.getData()) + 2, - obuffer.getLength() - 2, &data[2], data.size() - 2); + static_cast<const uint8_t *>(renderer.getData()) + 2, + renderer.getLength() - 2, &data[2], data.size() - 2); } TEST_F(Rdata_DNSKEY_Test, toWireBuffer) { diff --git a/src/lib/dns/tests/rdata_ds_like_unittest.cc b/src/lib/dns/tests/rdata_ds_like_unittest.cc index 9b294460d6..6172431d77 100644 --- a/src/lib/dns/tests/rdata_ds_like_unittest.cc +++ b/src/lib/dns/tests/rdata_ds_like_unittest.cc @@ -115,8 +115,8 @@ TYPED_TEST(Rdata_DS_LIKE_Test, toWireRenderer) { UnitTestUtil::readWireData("rdata_ds_fromWire", data); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, static_cast<const uint8_t*> - (this->obuffer.getData()) + 2, - this->obuffer.getLength() - 2, + (this->renderer.getData()) + 2, + this->renderer.getLength() - 2, &data[2], data.size() - 2); } diff --git a/src/lib/dns/tests/rdata_hinfo_unittest.cc b/src/lib/dns/tests/rdata_hinfo_unittest.cc index c52b2a05ed..c934a4ff19 100644 --- a/src/lib/dns/tests/rdata_hinfo_unittest.cc +++ b/src/lib/dns/tests/rdata_hinfo_unittest.cc @@ -94,8 +94,9 @@ TEST_F(Rdata_HINFO_Test, toWireRenderer) { HINFO hinfo(hinfo_str); hinfo.toWire(renderer); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(), - obuffer.getLength(), hinfo_rdata, sizeof(hinfo_rdata)); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), hinfo_rdata, + sizeof(hinfo_rdata)); } TEST_F(Rdata_HINFO_Test, compare) { diff --git a/src/lib/dns/tests/rdata_in_a_unittest.cc b/src/lib/dns/tests/rdata_in_a_unittest.cc index 47e2bfa480..af4369d0bc 100644 --- a/src/lib/dns/tests/rdata_in_a_unittest.cc +++ b/src/lib/dns/tests/rdata_in_a_unittest.cc @@ -78,7 +78,7 @@ TEST_F(Rdata_IN_A_Test, toWireBuffer) { TEST_F(Rdata_IN_A_Test, toWireRenderer) { rdata_in_a.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_in_a, sizeof(wiredata_in_a)); } diff --git a/src/lib/dns/tests/rdata_in_aaaa_unittest.cc b/src/lib/dns/tests/rdata_in_aaaa_unittest.cc index 6fd4d0ed61..c3e1e165a3 100644 --- a/src/lib/dns/tests/rdata_in_aaaa_unittest.cc +++ b/src/lib/dns/tests/rdata_in_aaaa_unittest.cc @@ -76,7 +76,7 @@ TEST_F(Rdata_IN_AAAA_Test, toWireBuffer) { TEST_F(Rdata_IN_AAAA_Test, toWireRenderer) { rdata_in_aaaa.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_in_aaaa, sizeof(wiredata_in_aaaa)); } diff --git a/src/lib/dns/tests/rdata_minfo_unittest.cc b/src/lib/dns/tests/rdata_minfo_unittest.cc index 30c7c3945f..78e8325f1c 100644 --- a/src/lib/dns/tests/rdata_minfo_unittest.cc +++ b/src/lib/dns/tests/rdata_minfo_unittest.cc @@ -142,15 +142,15 @@ TEST_F(Rdata_MINFO_Test, toWireRenderer) { vector<unsigned char> data; UnitTestUtil::readWireData("rdata_minfo_toWire1.wire", data); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t *>(obuffer.getData()), - obuffer.getLength(), &data[0], data.size()); + static_cast<const uint8_t *>(renderer.getData()), + renderer.getLength(), &data[0], data.size()); renderer.clear(); rdata_minfo2.toWire(renderer); vector<unsigned char> data2; UnitTestUtil::readWireData("rdata_minfo_toWire2.wire", data2); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t *>(obuffer.getData()), - obuffer.getLength(), &data2[0], data2.size()); + static_cast<const uint8_t *>(renderer.getData()), + renderer.getLength(), &data2[0], data2.size()); } TEST_F(Rdata_MINFO_Test, toText) { diff --git a/src/lib/dns/tests/rdata_mx_unittest.cc b/src/lib/dns/tests/rdata_mx_unittest.cc index c4c9757a35..36814ea1d2 100644 --- a/src/lib/dns/tests/rdata_mx_unittest.cc +++ b/src/lib/dns/tests/rdata_mx_unittest.cc @@ -68,12 +68,12 @@ TEST_F(Rdata_MX_Test, toWireRenderer) { vector<unsigned char> data; UnitTestUtil::readWireData("rdata_mx_toWire1", data); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(), - obuffer.getLength(), &data[0], data.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &data[0], data.size()); } TEST_F(Rdata_MX_Test, toWireBuffer) { - renderer.writeName(Name("example.com")); + Name("example.com").toWire(obuffer); rdata_mx.toWire(obuffer); vector<unsigned char> data; diff --git a/src/lib/dns/tests/rdata_naptr_unittest.cc b/src/lib/dns/tests/rdata_naptr_unittest.cc index f905943ec5..5abcaefaa2 100644 --- a/src/lib/dns/tests/rdata_naptr_unittest.cc +++ b/src/lib/dns/tests/rdata_naptr_unittest.cc @@ -140,8 +140,9 @@ TEST_F(Rdata_NAPTR_Test, toWireRenderer) { NAPTR naptr(naptr_str); naptr.toWire(renderer); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, obuffer.getData(), - obuffer.getLength(), naptr_rdata, sizeof(naptr_rdata)); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), naptr_rdata, + sizeof(naptr_rdata)); } TEST_F(Rdata_NAPTR_Test, toText) { diff --git a/src/lib/dns/tests/rdata_ns_unittest.cc b/src/lib/dns/tests/rdata_ns_unittest.cc index b8057831b9..47582ce00f 100644 --- a/src/lib/dns/tests/rdata_ns_unittest.cc +++ b/src/lib/dns/tests/rdata_ns_unittest.cc @@ -96,11 +96,11 @@ TEST_F(Rdata_NS_Test, toWireBuffer) { TEST_F(Rdata_NS_Test, toWireRenderer) { rdata_ns.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_ns, sizeof(wiredata_ns)); rdata_ns2.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_ns2, sizeof(wiredata_ns2)); } diff --git a/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc b/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc index 30110df397..51fef01bf7 100644 --- a/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc +++ b/src/lib/dns/tests/rdata_nsec3param_like_unittest.cc @@ -40,7 +40,7 @@ protected: NSEC3PARAMLikeTest() : salt_txt("1 1 1 D399EAAB" + getCommonText()), nosalt_txt("1 1 1 -" + getCommonText()), - obuffer(0), renderer(obuffer) + obuffer(0) {} RDATA_TYPE fromText(const string& rdata_text) { diff --git a/src/lib/dns/tests/rdata_nsec3param_unittest.cc b/src/lib/dns/tests/rdata_nsec3param_unittest.cc index 90313d0527..7558b42a74 100644 --- a/src/lib/dns/tests/rdata_nsec3param_unittest.cc +++ b/src/lib/dns/tests/rdata_nsec3param_unittest.cc @@ -94,8 +94,8 @@ TEST_F(Rdata_NSEC3PARAM_Test, toWireRenderer) { vector<unsigned char> data; UnitTestUtil::readWireData("rdata_nsec3param_fromWire1", data); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t *>(obuffer.getData()) + 2, - obuffer.getLength() - 2, &data[2], data.size() - 2); + static_cast<const uint8_t *>(renderer.getData()) + 2, + renderer.getLength() - 2, &data[2], data.size() - 2); } TEST_F(Rdata_NSEC3PARAM_Test, toWireBuffer) { diff --git a/src/lib/dns/tests/rdata_nsec_unittest.cc b/src/lib/dns/tests/rdata_nsec_unittest.cc index feb70c210d..88c6201b65 100644 --- a/src/lib/dns/tests/rdata_nsec_unittest.cc +++ b/src/lib/dns/tests/rdata_nsec_unittest.cc @@ -74,8 +74,8 @@ TEST_F(Rdata_NSEC_Test, toWireRenderer_NSEC) { vector<unsigned char> data; UnitTestUtil::readWireData("rdata_nsec_fromWire1", data); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t *>(obuffer.getData()) + 2, - obuffer.getLength() - 2, &data[2], data.size() - 2); + static_cast<const uint8_t *>(renderer.getData()) + 2, + renderer.getLength() - 2, &data[2], data.size() - 2); } TEST_F(Rdata_NSEC_Test, toWireBuffer_NSEC) { diff --git a/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc b/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc index 426a69e907..d7bce964d6 100644 --- a/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc +++ b/src/lib/dns/tests/rdata_nsecbitmap_unittest.cc @@ -264,7 +264,7 @@ TEST_F(NSEC3BitmapTest, emptyMap) { // Same for MessageRenderer. obuffer.clear(); - MessageRenderer renderer(obuffer); + MessageRenderer renderer; renderer.writeUint16(rdlen); empty_nsec3.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), diff --git a/src/lib/dns/tests/rdata_ptr_unittest.cc b/src/lib/dns/tests/rdata_ptr_unittest.cc index 7f5de2056b..86160fbab7 100644 --- a/src/lib/dns/tests/rdata_ptr_unittest.cc +++ b/src/lib/dns/tests/rdata_ptr_unittest.cc @@ -100,11 +100,11 @@ TEST_F(Rdata_PTR_Test, toWireBuffer) { TEST_F(Rdata_PTR_Test, toWireRenderer) { rdata_ptr.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_ptr, sizeof(wiredata_ptr)); rdata_ptr2.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_ptr2, sizeof(wiredata_ptr2)); } diff --git a/src/lib/dns/tests/rdata_rp_unittest.cc b/src/lib/dns/tests/rdata_rp_unittest.cc index 07f5a932aa..20f32b9539 100644 --- a/src/lib/dns/tests/rdata_rp_unittest.cc +++ b/src/lib/dns/tests/rdata_rp_unittest.cc @@ -38,7 +38,7 @@ protected: // this also serves as a test for "from text" constructor in a normal // case. rdata_rp("root.example.com. rp-text.example.com."), - obuffer(0), renderer(obuffer) + obuffer(0) {} const Name mailbox_name, text_name; diff --git a/src/lib/dns/tests/rdata_soa_unittest.cc b/src/lib/dns/tests/rdata_soa_unittest.cc index 07c24d5074..a9d782c2be 100644 --- a/src/lib/dns/tests/rdata_soa_unittest.cc +++ b/src/lib/dns/tests/rdata_soa_unittest.cc @@ -56,8 +56,8 @@ TEST_F(Rdata_SOA_Test, toWireRenderer) { vector<unsigned char> data; UnitTestUtil::readWireData("rdata_soa_fromWire", data); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - static_cast<const uint8_t *>(obuffer.getData()) + 2, - obuffer.getLength() - 2, &data[2], data.size() - 2); + static_cast<const uint8_t *>(renderer.getData()) + 2, + renderer.getLength() - 2, &data[2], data.size() - 2); } TEST_F(Rdata_SOA_Test, toWireBuffer) { diff --git a/src/lib/dns/tests/rdata_srv_unittest.cc b/src/lib/dns/tests/rdata_srv_unittest.cc index 3394f43aef..b194b1c945 100644 --- a/src/lib/dns/tests/rdata_srv_unittest.cc +++ b/src/lib/dns/tests/rdata_srv_unittest.cc @@ -134,12 +134,12 @@ TEST_F(Rdata_SRV_Test, toWireBuffer) { TEST_F(Rdata_SRV_Test, toWireRenderer) { rdata_srv.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_srv, sizeof(wiredata_srv)); renderer.clear(); rdata_srv2.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_srv2, sizeof(wiredata_srv2)); } diff --git a/src/lib/dns/tests/rdata_unittest.cc b/src/lib/dns/tests/rdata_unittest.cc index fa791dc053..5be06e8693 100644 --- a/src/lib/dns/tests/rdata_unittest.cc +++ b/src/lib/dns/tests/rdata_unittest.cc @@ -38,8 +38,7 @@ namespace isc { namespace dns { namespace rdata { RdataTest::RdataTest() : - obuffer(0), renderer(obuffer), - rdata_nomatch(createRdata(RRType(0), RRClass(1), "\\# 0")) + obuffer(0), rdata_nomatch(createRdata(RRType(0), RRClass(1), "\\# 0")) {} RdataPtr @@ -245,7 +244,7 @@ TEST_F(Rdata_Unknown_Test, toWireBuffer) { TEST_F(Rdata_Unknown_Test, toWireRenderer) { rdata_unknown.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata_unknown, sizeof(wiredata_unknown)); } diff --git a/src/lib/dns/tests/rdatafields_unittest.cc b/src/lib/dns/tests/rdatafields_unittest.cc index d6192209ff..ef83ed4b26 100644 --- a/src/lib/dns/tests/rdatafields_unittest.cc +++ b/src/lib/dns/tests/rdatafields_unittest.cc @@ -36,9 +36,7 @@ using isc::util::InputBuffer; namespace { class RdataFieldsTest : public ::testing::Test { protected: - RdataFieldsTest() : obuffer(0), renderer_buffer(0), - renderer(renderer_buffer), - ns_name("example.com"), + RdataFieldsTest() : obuffer(0), ns_name("example.com"), other_name("www.example.com") {} void constructCommonTests(const RdataFields& fields, @@ -49,7 +47,6 @@ protected: void constructCommonTestsRRSIG(const RdataFields& fields); void constructCommonTestsOPT(const RdataFields& fields); OutputBuffer obuffer; - OutputBuffer renderer_buffer; MessageRenderer renderer; const Name ns_name; const Name other_name; diff --git a/src/lib/dns/tests/rrclass_unittest.cc b/src/lib/dns/tests/rrclass_unittest.cc index 15f9a8c6e1..6156be5fcc 100644 --- a/src/lib/dns/tests/rrclass_unittest.cc +++ b/src/lib/dns/tests/rrclass_unittest.cc @@ -28,7 +28,7 @@ using namespace isc::util; namespace { class RRClassTest : public ::testing::Test { protected: - RRClassTest() : obuffer(0), renderer(obuffer) {} + RRClassTest() : obuffer(0) {} OutputBuffer obuffer; MessageRenderer renderer; @@ -116,7 +116,7 @@ TEST_F(RRClassTest, toWireRenderer) { rrclass_max.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata, sizeof(wiredata)); } diff --git a/src/lib/dns/tests/rrset_unittest.cc b/src/lib/dns/tests/rrset_unittest.cc index f9513411c7..a6bfe5695b 100644 --- a/src/lib/dns/tests/rrset_unittest.cc +++ b/src/lib/dns/tests/rrset_unittest.cc @@ -38,7 +38,7 @@ using namespace isc::dns::rdata; namespace { class RRsetTest : public ::testing::Test { protected: - RRsetTest() : buffer(0), renderer(buffer), + RRsetTest() : buffer(0), test_name("test.example.com"), test_domain("example.com"), test_nsname("ns.example.com"), @@ -201,8 +201,8 @@ TEST_F(RRsetTest, toWireRenderer) { rrset_ns.toWire(renderer); UnitTestUtil::readWireData("rrset_toWire2", wiredata); - EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, buffer.getData(), - buffer.getLength(), &wiredata[0], wiredata.size()); + EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, renderer.getData(), + renderer.getLength(), &wiredata[0], wiredata.size()); // toWire() cannot be performed for an empty RRset. renderer.clear(); diff --git a/src/lib/dns/tests/rrttl_unittest.cc b/src/lib/dns/tests/rrttl_unittest.cc index fe75eb62e5..1c1ae9765b 100644 --- a/src/lib/dns/tests/rrttl_unittest.cc +++ b/src/lib/dns/tests/rrttl_unittest.cc @@ -28,7 +28,7 @@ using namespace isc::util; namespace { class RRTTLTest : public ::testing::Test { protected: - RRTTLTest() : obuffer(0), renderer(obuffer) {} + RRTTLTest() : obuffer(0) {} OutputBuffer obuffer; MessageRenderer renderer; @@ -114,7 +114,7 @@ TEST_F(RRTTLTest, toWireRenderer) { ttl_max.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata, sizeof(wiredata)); } diff --git a/src/lib/dns/tests/rrtype_unittest.cc b/src/lib/dns/tests/rrtype_unittest.cc index 12f6001f92..28ecee65d4 100644 --- a/src/lib/dns/tests/rrtype_unittest.cc +++ b/src/lib/dns/tests/rrtype_unittest.cc @@ -28,7 +28,7 @@ using namespace isc::util; namespace { class RRTypeTest : public ::testing::Test { protected: - RRTypeTest() : obuffer(0), renderer(obuffer) {} + RRTypeTest() : obuffer(0) {} OutputBuffer obuffer; MessageRenderer renderer; @@ -120,7 +120,7 @@ TEST_F(RRTypeTest, toWireRenderer) { rrtype_max.toWire(renderer); EXPECT_PRED_FORMAT4(UnitTestUtil::matchWireData, - obuffer.getData(), obuffer.getLength(), + renderer.getData(), renderer.getLength(), wiredata, sizeof(wiredata)); } diff --git a/src/lib/dns/tests/tsig_unittest.cc b/src/lib/dns/tests/tsig_unittest.cc index 7944b2939e..ac503e50d8 100644 --- a/src/lib/dns/tests/tsig_unittest.cc +++ b/src/lib/dns/tests/tsig_unittest.cc @@ -71,7 +71,7 @@ protected: TSIGTest() : tsig_ctx(NULL), qid(0x2d65), test_name("www.example.com"), badkey_name("badkey.example.com"), test_class(RRClass::IN()), - test_ttl(86400), message(Message::RENDER), buffer(0), renderer(buffer), + test_ttl(86400), message(Message::RENDER), dummy_data(1024, 0xdd), // should be sufficiently large for all tests dummy_record(badkey_name, any::TSIG(TSIGKey::HMACMD5_NAME(), 0x4da8877a, @@ -125,7 +125,6 @@ protected: const RRClass test_class; const RRTTL test_ttl; Message message; - OutputBuffer buffer; MessageRenderer renderer; vector<uint8_t> secret; vector<uint8_t> dummy_data; diff --git a/src/lib/dns/tests/tsigrecord_unittest.cc b/src/lib/dns/tests/tsigrecord_unittest.cc index e1b3e9318c..532681ac2d 100644 --- a/src/lib/dns/tests/tsigrecord_unittest.cc +++ b/src/lib/dns/tests/tsigrecord_unittest.cc @@ -46,7 +46,7 @@ protected: test_mac.size(), &test_mac[0], 0x2d65, 0, 0, NULL)), test_record(test_name, test_rdata), - buffer(0), renderer(buffer) + buffer(0) {} const Name test_name; vector<unsigned char> test_mac; |