try {
buildFromTextHelper(lexer);
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText, "Failed to construct " <<
+ RRType(typeCode) << " RDATA from '" << txtstr <<
+ "': extra new line");
+ }
} catch (const MasterLexer::LexerError& ex) {
isc_throw(InvalidRdataText, "Failed to construct " <<
- RRType(typeCode) << " RDATA from " << txtstr << ": "
+ RRType(typeCode) << " RDATA from '" << txtstr << "': "
<< ex.what());
}
}
std::stringstream ss;
ss << "Test-String\n";
ss << "\"Test-String\"\n"; // explicitly surrounded by '"'s
- ss << "(\n\"Test-String\")\n"; // multi-line text with ()
+ ss << "(\n \"Test-String\" )\n"; // multi-line text with ()
ss << "\"\"\n"; // empty string (note: still valid char-str)
ss << string(255, 'a') << "\n"; // Longest possible character-string.
ss << string(256, 'a') << "\n"; // char-string too long
EXPECT_EQ(MasterToken::END_OF_LINE, this->lexer.getNextToken().getType());
// multi-line input with ()
- EXPECT_EQ(0, TypeParam("(\n\"Test-String\")").compare(*rdata));
+ EXPECT_EQ(0, TypeParam("(\n \"Test-String\" )").compare(*rdata));
EXPECT_EQ(0, TypeParam(this->lexer, NULL, MasterLoader::MANY_ERRORS,
this->loader_cb).compare(*rdata));
EXPECT_EQ(MasterToken::END_OF_LINE, this->lexer.getNextToken().getType());
}
}
+TYPED_TEST(Rdata_TXT_LIKE_Test, createFromTextExtra) {
+ // This is for the std::string version only: the input must end with EOF;
+ // an extra new-line will result in an exception.
+ EXPECT_THROW(TypeParam("\"Test-String\"\n"), InvalidRdataText);
+ // Same if there's a space before '\n'
+ EXPECT_THROW(TypeParam("\"Test-String\" \n"), InvalidRdataText);
+}
+
TYPED_TEST(Rdata_TXT_LIKE_Test, fromTextEmpty) {
// If the input text doesn't contain any character-string, it should be
// rejected