BIND 10 trac2375, updated. 89a6e668f647c323849e78449f00efad1ca624c4 [2375] A fake state class
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Nov 12 18:24:31 UTC 2012
The branch, trac2375 has been updated
via 89a6e668f647c323849e78449f00efad1ca624c4 (commit)
from 8a5338e994c6509c38fb024f1212e629b334c9b4 (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 89a6e668f647c323849e78449f00efad1ca624c4
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Nov 12 19:24:21 2012 +0100
[2375] A fake state class
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/master_lexer.cc | 5 +++++
src/lib/dns/master_lexer_state.h | 5 +++++
src/lib/dns/tests/master_lexer_unittest.cc | 29 ++++++++++++++++++++++++++++
3 files changed, 39 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_lexer.cc b/src/lib/dns/master_lexer.cc
index f4ded23..76c40e1 100644
--- a/src/lib/dns/master_lexer.cc
+++ b/src/lib/dns/master_lexer.cc
@@ -178,6 +178,11 @@ State::getParenCount(const MasterLexer& lexer) const {
return (lexer.impl_->paren_count_);
}
+void
+State::setToken(MasterLexer& lexer, const Token& token) {
+ lexer.impl_->token_ = token;
+}
+
class CRLF : public State {
public:
CRLF() {}
diff --git a/src/lib/dns/master_lexer_state.h b/src/lib/dns/master_lexer_state.h
index 0d00049..aad557e 100644
--- a/src/lib/dns/master_lexer_state.h
+++ b/src/lib/dns/master_lexer_state.h
@@ -126,6 +126,11 @@ protected:
MasterLexer::MasterLexerImpl* getLexerImpl(MasterLexer& lexer) const {
return (lexer.impl_);
}
+
+ /// \brief Set the token in master lexer.
+ ///
+ /// The reason is similar as with getLexerImpl.
+ void setToken(MasterLexer& lexer, const MasterLexer::Token& token) const;
};
} // namespace master_lexer_internal
diff --git a/src/lib/dns/tests/master_lexer_unittest.cc b/src/lib/dns/tests/master_lexer_unittest.cc
index 34d9ab7..0b19984 100644
--- a/src/lib/dns/tests/master_lexer_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_unittest.cc
@@ -15,10 +15,12 @@
#include <exceptions/exceptions.h>
#include <dns/master_lexer.h>
+#include <dns/master_lexer_state.h>
#include <gtest/gtest.h>
#include <boost/lexical_cast.hpp>
+#include <boost/function.hpp>
#include <string>
#include <sstream>
@@ -30,6 +32,33 @@ using boost::lexical_cast;
namespace {
+// A fake state that just eats something from the input, pushes
+// a given token and calls a callback if it is set. It refers to
+// another state to return.
+class FakeState : public master_lexer_internal::State {
+public:
+ FakeState(const State* next, MasterLexer::Token* token = NULL,
+ const boost::function<void ()>& callback =
+ boost::function<void ()>()) :
+ next_(next),
+ token_(token),
+ callback_(callback)
+ {}
+ virtual const State* handle(MasterLexer& lexer) const {
+ if (token_ != NULL) {
+ setToken(lexer, *token_);
+ }
+ if (!callback_.empty()) {
+ callback_();
+ }
+ return (next_);
+ }
+private:
+ const State* const next_;
+ MasterLexer::Token* const token_;
+ const boost::function<void ()> callback_;
+};
+
class MasterLexerTest : public ::testing::Test {
protected:
MasterLexerTest() :
More information about the bind10-changes
mailing list