Commit f3259cf1 authored by Thomas Markwalder's avatar Thomas Markwalder

[2355] Removed element type checking from StringParser::build. This broke

a unit test in DHCP4, and it appears we rely on being able to set a string
configuration value from any element type.
parent 36d83740
......@@ -173,18 +173,8 @@ StringParser::StringParser(const std::string& param_name,
}
void StringParser::build(ConstElementPtr value) {
#if 0
value_ = value->str();
boost::erase_all(value_, "\"");
#else
try {
value_ = value->stringValue();
boost::erase_all(value_, "\"");
} catch (const isc::data::TypeError &) {
isc_throw(BadValue, " Wrong value type for " << param_name_
<< " : build called with a non-boolean element.");
}
#endif
}
void StringParser::commit() {
......
......@@ -97,7 +97,7 @@ TEST_F(DhcpParserTest, booleanParserTest) {
///
/// Verifies that the parser:
/// 1. Does not allow empty for storage.
/// 2. Rejects a non-string element.
/// 2. Builds with a nont string value.
/// 3. Builds with a string value.
/// 4. Updates storage upon commit.
TEST_F(DhcpParserTest, stringParserTest) {
......@@ -112,13 +112,13 @@ TEST_F(DhcpParserTest, stringParserTest) {
StringStoragePtr storage(new StringStorage());
StringParser parser(name, storage);
// Verify that parser with rejects a non-string element.
ElementPtr wrong_element = Element::create(9999);
EXPECT_THROW(parser.build(wrong_element), isc::BadValue);
// Verify that parser with accepts a non-string element.
ElementPtr element = Element::create(9999);
EXPECT_NO_THROW(parser.build(element));
// Verify that parser will build with a string value.
const std::string test_value = "test value";
ElementPtr element = Element::create(test_value);
element = Element::create(test_value);
ASSERT_NO_THROW(parser.build(element));
// Verify that commit updates storage.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment