Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/test/dns_tests.cpp
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(parse_name_qname_length_tests) { | ||||
// Check behavior for a name that is the maximum length | // Check behavior for a name that is the maximum length | ||||
std::string maxLengthQName = maxLengthLabel + '.' + maxLengthLabel + '.' + | std::string maxLengthQName = maxLengthLabel + '.' + maxLengthLabel + '.' + | ||||
maxLengthLabel + '.' + maxLengthLabel; | maxLengthLabel + '.' + maxLengthLabel; | ||||
BOOST_CHECK_EQUAL(maxLengthQName.size(), MAX_QUERY_NAME_LENGTH); | BOOST_CHECK_EQUAL(maxLengthQName.size(), MAX_QUERY_NAME_LENGTH); | ||||
CheckParseName(maxLengthQName); | CheckParseName(maxLengthQName); | ||||
// Check that a query name that is too long causes an error | // Check that a query name that is too long causes an error | ||||
std::string overSizedQName = maxLengthQName; | |||||
// Split the last label into two while adding an extra character to make | |||||
// sure the function does not error because of an oversized label | |||||
overSizedQName.insert(overSizedQName.end() - 3, '.'); | |||||
// Allocates an extra large buffer to guarantee an error is not caused by | // Allocates an extra large buffer to guarantee an error is not caused by | ||||
// the buffer size | // the buffer size | ||||
CheckParseNameError(maxLengthQName + "a", -1, 2 * maxLengthQName.size()); | CheckParseNameError(overSizedQName, -1, 2 * overSizedQName.size()); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |