Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/test/dns_tests.cpp
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(parse_name_label_tests) { | ||||
// Check behavior for name with maximum length label | // Check behavior for name with maximum length label | ||||
const std::string maxLengthLabel(MAX_LABEL_LENGTH, 'a'); | const std::string maxLengthLabel(MAX_LABEL_LENGTH, 'a'); | ||||
CheckParseName("www." + maxLengthLabel + ".com"); | CheckParseName("www." + maxLengthLabel + ".com"); | ||||
// Check that an oversized label causes an error | // Check that an oversized label causes an error | ||||
CheckParseNameError("www." + maxLengthLabel + "a.com", -1); | CheckParseNameError("www." + maxLengthLabel + "a.com", -1); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(parse_name_qname_length_tests) { | |||||
const std::string maxLengthLabel(MAX_LABEL_LENGTH, 'a'); | |||||
// Check behavior for a name that is the maximum length | |||||
std::string maxLengthQName = maxLengthLabel + '.' + maxLengthLabel + '.' + | |||||
maxLengthLabel + '.' + maxLengthLabel; | |||||
BOOST_CHECK_EQUAL(maxLengthQName.size(), MAX_QUERY_NAME_LENGTH); | |||||
CheckParseName(maxLengthQName); | |||||
// Check that a query name that is too long causes an error | |||||
// Allocates an extra large buffer to guarantee an error is not caused by | |||||
// the buffer size | |||||
CheckParseNameError(maxLengthQName + "a", -1, 2 * maxLengthQName.size()); | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |