Browse Source

[2373] added a test for qstring: confirm separators are regarded as part of str

JINMEI Tatuya 12 years ago
parent
commit
843eaa0b84
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/lib/dns/tests/master_lexer_state_unittest.cc

+ 11 - 1
src/lib/dns/tests/master_lexer_state_unittest.cc

@@ -362,7 +362,12 @@ TEST_F(MasterLexerStateTest, stringEscape) {
 
 TEST_F(MasterLexerStateTest, quotedString) {
     ss << "\"ignore-quotes\"\n";
-    ss << "\"quoted string\" ";
+    ss << "\"quoted string\" "; // space is part of the qstring
+    // also check other separator characters. note that \r doesn't cause
+    // UNBALANCED_QUOTES.  Not sure if it's intentional, but that's how the
+    // BIND 9 version works, so we follow it (it should be too minor to matter
+    // in practice anyway)
+    ss << "\"quoted()\t\rstring\" ";
     ss << "\"escape\\ in quote\" ";
     ss << "\"escaped\\\"\" ";
     ss << "\"escaped backslash\\\\\" ";
@@ -384,6 +389,11 @@ TEST_F(MasterLexerStateTest, quotedString) {
     EXPECT_EQ(s_null, s_qstring.handle(lexer));
     stringTokenCheck("quoted string", s_string.getToken(lexer), true);
 
+    // Also checks other separator characters within a qstring
+    EXPECT_EQ(&s_qstring, State::start(lexer, options));
+    EXPECT_EQ(s_null, s_qstring.handle(lexer));
+    stringTokenCheck("quoted()\t\rstring", s_string.getToken(lexer), true);
+
     // escape character mostly doesn't have any effect in the qstring
     // processing
     EXPECT_EQ(&s_qstring, State::start(lexer, options));