BIND 10 trac2375, updated. 651f18e536175749b5e1bf0e7c9e2e9ceff3214d [2375] Merge branch 'trac2375' of ssh://git.bind10.isc.org/var/bind10/git/bind10 into trac2375 Conflicts: src/lib/dns/tests/master_lexer_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Nov 20 07:49:32 UTC 2012


The branch, trac2375 has been updated
       via  651f18e536175749b5e1bf0e7c9e2e9ceff3214d (commit)
       via  789881ed30e1574554af513953772ad4888c0d8b (commit)
       via  e2168eab4f4b6e11fb5efd7d0951e2b2663c4103 (commit)
      from  36d0f35e46b9b292c9926f5a804bfcf3cc660343 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 651f18e536175749b5e1bf0e7c9e2e9ceff3214d
Merge: 789881e 36d0f35
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Tue Nov 20 16:49:27 2012 +0900

    [2375] Merge branch 'trac2375' of ssh://git.bind10.isc.org/var/bind10/git/bind10 into trac2375
    Conflicts:
    	src/lib/dns/tests/master_lexer_unittest.cc

commit 789881ed30e1574554af513953772ad4888c0d8b
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Tue Nov 20 16:47:54 2012 +0900

    [2375] fixed a typo in a comment

commit e2168eab4f4b6e11fb5efd7d0951e2b2663c4103
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Thu Nov 15 14:00:40 2012 -0800

    [2375] some style matters: mostly about constness, and folded a long line.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/master_lexer.cc                |    6 ++--
 src/lib/dns/master_lexer_state.h           |    2 +-
 src/lib/dns/tests/master_lexer_unittest.cc |   52 +++++++++++++++-------------
 3 files changed, 31 insertions(+), 29 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_lexer.cc b/src/lib/dns/master_lexer.cc
index 3040ffe..36cb613 100644
--- a/src/lib/dns/master_lexer.cc
+++ b/src/lib/dns/master_lexer.cc
@@ -355,7 +355,7 @@ namespace {
 class FakeState : public State {
 public:
     FakeState(const State* next, size_t eat_chars,
-              MasterLexer::Token* token,
+              const MasterLexer::Token* token,
               int paren_change, const bool* set_eol,
               const boost::function<void (const std::string&)>& callback) :
         next_(next),
@@ -385,7 +385,7 @@ public:
 private:
     const State* const next_;
     size_t eat_chars_;
-    MasterLexer::Token* const token_;
+    const MasterLexer::Token* const token_;
     const int paren_change_;
     const bool* const set_eol_;
     const boost::function<void (const std::string&)> callback_;
@@ -395,7 +395,7 @@ private:
 
 State*
 State::getFakeState(const State* next, size_t eat_chars,
-                    MasterLexer::Token* token,
+                    const MasterLexer::Token* token,
                     int paren_change, const bool* set_eol,
                     const boost::function<void (const std::string&)>& callback)
 {
diff --git a/src/lib/dns/master_lexer_state.h b/src/lib/dns/master_lexer_state.h
index 0c63b8f..75d2d32 100644
--- a/src/lib/dns/master_lexer_state.h
+++ b/src/lib/dns/master_lexer_state.h
@@ -123,7 +123,7 @@ public:
     ///
     /// The caller is responsible for deleting the State.
     static State* getFakeState(const State* next, size_t eat_chars,
-                               MasterLexer::Token* token = NULL,
+                               const MasterLexer::Token* token = NULL,
                                int paren_change = 0,
                                const bool* set_eol = NULL,
                                const boost::function<void
diff --git a/src/lib/dns/tests/master_lexer_unittest.cc b/src/lib/dns/tests/master_lexer_unittest.cc
index b076bfd..57d16a9 100644
--- a/src/lib/dns/tests/master_lexer_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_unittest.cc
@@ -36,8 +36,8 @@ using master_lexer_internal::State;
 
 namespace {
 
-// This acts like the normal MasterLexer. It, however, allows to mock the start()
-// method to return some given state instead of the auto-detected ones.
+// This acts like the normal MasterLexer. It, however, allows to mock the
+// start() method to return some given state instead of the auto-detected ones.
 class TestedMasterLexer : public MasterLexer {
 public:
     TestedMasterLexer() :
@@ -178,33 +178,33 @@ TEST_F(MasterLexerTest, tokenFromStart) {
             // We don't have access directly inside the implementation.
             // We get the fake state, run it to install the token.
             // Then we just delete it ourself and return NULL.
-            State* state(State::getFakeState(NULL, 0, &token_));
+            const State* state(State::getFakeState(NULL, 0, &token_));
             state->handle(*this);
             delete state;
             return (NULL);
         }
     private:
-        MasterLexer::Token token_;
+        const MasterLexer::Token token_;
     } lexer;
     lexer.pushSource(ss);
 
     // The token gets out.
-    MasterLexer::Token generated(lexer.getNextToken());
+    const MasterLexer::Token generated(lexer.getNextToken());
     EXPECT_EQ(MasterLexer::Token::END_OF_LINE, generated.getType());
 }
 
 // Getting a token with a single iteration through the states.
 TEST_F(MasterLexerTest, simpleGetToken) {
     // Prepare the fake state.
-    MasterLexer::Token token(MasterLexer::Token::END_OF_LINE);
-    scoped_ptr<State> state(State::getFakeState(NULL, 3, &token));
+    const MasterLexer::Token token(MasterLexer::Token::END_OF_LINE);
+    scoped_ptr<const State> state(State::getFakeState(NULL, 3, &token));
     lexer.pushFakeStart(state.get());
     // Push some source inside.
     ss << "12345";
     lexer.pushSource(ss);
 
     // Get the token.
-    MasterLexer::Token generated(lexer.getNextToken());
+    const MasterLexer::Token generated(lexer.getNextToken());
     // It is the same token (well, on a different address)
     // We can't compare directly, so compare types.
     EXPECT_EQ(token.getType(), generated.getType());
@@ -221,17 +221,17 @@ TEST_F(MasterLexerTest, simpleGetToken) {
 // survive and be returned.
 TEST_F(MasterLexerTest, chainGetToken) {
     // Build the states
-    MasterLexer::Token t1(MasterLexer::Token::END_OF_LINE);
-    MasterLexer::Token t2(MasterLexer::Token::INITIAL_WS);
-    scoped_ptr<State> s2(State::getFakeState(NULL, 1, &t2));
-    scoped_ptr<State> s1(State::getFakeState(s2.get(), 2, &t1));
+    const MasterLexer::Token t1(MasterLexer::Token::END_OF_LINE);
+    const MasterLexer::Token t2(MasterLexer::Token::INITIAL_WS);
+    scoped_ptr<const State> s2(State::getFakeState(NULL, 1, &t2));
+    scoped_ptr<const State> s1(State::getFakeState(s2.get(), 2, &t1));
     lexer.pushFakeStart(s1.get());
     // Put something into the source
     ss << "12345";
     lexer.pushSource(ss);
 
     // Get the token.
-    MasterLexer::Token generated(lexer.getNextToken());
+    const MasterLexer::Token generated(lexer.getNextToken());
     // It is the same token as the second one (well, on a different address)
     // We can't compare directly, so compare types.
     EXPECT_EQ(t2.getType(), generated.getType());
@@ -284,19 +284,21 @@ TEST_F(MasterLexerTest, ungetSimple) {
     const bool true_value = true, false_value = false;
     // Make sure we change the state to non-default, so we return to previous
     // not default state.
-    MasterLexer::Token t0(MasterLexer::Token::INITIAL_WS);
-    scoped_ptr<State> s0(State::getFakeState(NULL, 1, &t0, 1, &true_value));
+    const MasterLexer::Token t0(MasterLexer::Token::INITIAL_WS);
+    scoped_ptr<const State> s0(State::getFakeState(NULL, 1, &t0, 1,
+                                                   &true_value));
     lexer.pushFakeStart(s0.get());
     EXPECT_EQ(MasterLexer::Token::INITIAL_WS, lexer.getNextToken().getType());
 
     // Prepare the token to get and return
     const std::string expected = "234";
-    MasterLexer::Token token(MasterLexer::Token::END_OF_LINE);
-    // Change the internal state with it too. So we can check it is retured.
-    scoped_ptr<State> state(State::getFakeState(NULL, 3, &token, 1,
-                                                &false_value,
-                                                boost::bind(&checkInput,
-                                                            expected, _1)));
+    const MasterLexer::Token token(MasterLexer::Token::END_OF_LINE);
+    // Change the internal state with it too. So we can check it is returned.
+    scoped_ptr<const State> state(State::getFakeState(NULL, 3, &token, 1,
+                                                      &false_value,
+                                                      boost::bind(&checkInput,
+                                                                  expected,
+                                                                  _1)));
     lexer.pushFakeStart(state.get());
 
     // Check the internal state before getting the token
@@ -394,10 +396,10 @@ TEST_F(MasterLexerTest, getTokenExceptions) {
     // Then the thing should get to the previous state and getting the
     // token the usual way without mock should work.
     const bool true_value = true;
-    boost::scoped_ptr<State> s2(State::getFakeState(NULL, 3, NULL, 0, NULL,
-                                                    &doThrow));
-    boost::scoped_ptr<State> s1(State::getFakeState(s2.get(), 3, NULL, 1,
-                                                    &true_value));
+    boost::scoped_ptr<const State> s2(State::getFakeState(NULL, 3, NULL, 0,
+                                                          NULL, &doThrow));
+    boost::scoped_ptr<const State> s1(State::getFakeState(s2.get(), 3, NULL, 1,
+                                                          &true_value));
     lexer.pushFakeStart(s1.get());
 
     // Getting the token with the fake start should throw. But then, the



More information about the bind10-changes mailing list