|
@@ -0,0 +1,56 @@
|
|
|
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
|
|
+//
|
|
|
+// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
+// purpose with or without fee is hereby granted, provided that the above
|
|
|
+// copyright notice and this permission notice appear in all copies.
|
|
|
+//
|
|
|
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
+// PERFORMANCE OF THIS SOFTWARE.
|
|
|
+
|
|
|
+#include <dns/master_lexer.h>
|
|
|
+
|
|
|
+#include <gtest/gtest.h>
|
|
|
+
|
|
|
+#include <boost/lexical_cast.hpp>
|
|
|
+
|
|
|
+#include <string>
|
|
|
+#include <sstream>
|
|
|
+
|
|
|
+using namespace isc::dns;
|
|
|
+using std::string;
|
|
|
+using std::stringstream;
|
|
|
+using boost::lexical_cast;
|
|
|
+
|
|
|
+namespace {
|
|
|
+
|
|
|
+class MasterLexerTest : public ::testing::Test {
|
|
|
+protected:
|
|
|
+ MasterLexerTest() {}
|
|
|
+
|
|
|
+ MasterLexer lexer;
|
|
|
+ stringstream ss;
|
|
|
+};
|
|
|
+
|
|
|
+TEST_F(MasterLexerTest, preOPen) {
|
|
|
+ // Initially sources stack is empty, and getXXX() returns accordingly.
|
|
|
+ EXPECT_TRUE(lexer.getSourceName().empty());
|
|
|
+ EXPECT_EQ(0, lexer.getSourceLine());
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(MasterLexerTest, openStream) {
|
|
|
+ lexer.open(ss);
|
|
|
+ EXPECT_EQ(string("stream-") + lexical_cast<string>(&ss),
|
|
|
+ lexer.getSourceName());
|
|
|
+
|
|
|
+ // From the point of view of this test, we only have to check (though
|
|
|
+ // indirectly) getSourceLine calls InputSource::getCurrentLine. It should
|
|
|
+ // return 1 initially.
|
|
|
+ EXPECT_EQ(1, lexer.getSourceLine());
|
|
|
+}
|
|
|
+
|
|
|
+}
|