Browse Source

[2375] Check an unbalanced parenthesis is detected

Michal 'vorner' Vaner 12 years ago
parent
commit
12aac74652
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/lib/dns/tests/master_lexer_unittest.cc

+ 13 - 0
src/lib/dns/tests/master_lexer_unittest.cc

@@ -270,6 +270,19 @@ TEST_F(MasterLexerTest, eof) {
     EXPECT_THROW(lexer.getNextToken(), isc::InvalidOperation);
 }
 
+// Check we properly return error when there's an opened parentheses and no
+// closing one
+TEST_F(MasterLexerTest, getUnbalanced) {
+    ss << "(\"string\"";
+    lexer.pushSource(ss);
+
+    // The string gets out first
+    EXPECT_EQ(MasterLexer::Token::STRING, lexer.getNextToken().getType());
+    // Then an unbalanced parethsis
+    EXPECT_EQ(MasterLexer::Token::UNBALANCED_PAREN,
+              lexer.getNextToken().getErrorCode());
+}
+
 void
 checkInput(const std::string& expected, const std::string& received) {
     EXPECT_EQ(expected, received);