Browse Source

one more test case: member function callback with boost.bind.

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac423@3778 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 14 years ago
parent
commit
4861a979db
1 changed files with 20 additions and 1 deletions
  1. 20 1
      src/lib/dns/tests/master_unittest.cc

+ 20 - 1
src/lib/dns/tests/master_unittest.cc

@@ -19,6 +19,8 @@
 #include <string>
 #include <vector>
 
+#include <boost/bind.hpp>
+
 #include <gtest/gtest.h>
 
 #include <dns/master.h>
@@ -49,10 +51,15 @@ class MasterTest : public ::testing::Test {
 protected:
     MasterTest() : origin("example.com"), zclass(RRClass::IN()),
                    callback(results) {}
+public:
+    void rrsetCallback(ConstRRsetPtr rrset) {
+        results.push_back(rrset);
+    }
+protected:
     Name origin;
     RRClass zclass;
-    vector<ConstRRsetPtr> results;
     stringstream rr_stream;
+    vector<ConstRRsetPtr> results;
     TestCallback callback;
 };
 
@@ -85,6 +92,18 @@ TEST_F(MasterTest, loadWithFunctionCallback) {
     EXPECT_EQ(soa_rr, results[2]->toText());
 }
 
+TEST_F(MasterTest, loadWithMemFunctionCallback) {
+    // The same test as loadRRs but using a class member function (with a
+    // help of Boost.bind)
+    rr_stream << txt_rr << a_rr1 << soa_rr;
+    masterLoad(rr_stream, origin, zclass,
+               boost::bind(&MasterTest::rrsetCallback, this, _1));
+    ASSERT_EQ(3, results.size());
+    EXPECT_EQ(txt_rr, results[0]->toText());
+    EXPECT_EQ(a_rr1, results[1]->toText());
+    EXPECT_EQ(soa_rr, results[2]->toText());
+}
+
 TEST_F(MasterTest, loadComments) {
     rr_stream << ";; comment line, should be skipped\n"
               << "\n"           // blank line (should be skipped)