13#include <boost/test/unit_test.hpp>
20BOOST_AUTO_TEST_SUITE(parse_name_tests)
26 for (
size_t nameFieldEndIndex = 0; nameFieldEndIndex < nameField.size();
27 nameFieldEndIndex++) {
29 const uint8_t *nameFieldBegin = nameField.data();
31 &nameFieldBegin, nameFieldBegin + nameFieldEndIndex,
32 nameField.data(), parsedQueryName.data(), parsedQueryName.size());
38 size_t outputBufferSize = 0;
39 while (outputBufferSize <= queryName.size()) {
40 std::vector<char> parsedQueryName(outputBufferSize, 0);
41 const uint8_t *nameFieldBegin = nameField.data();
43 &nameFieldBegin, nameFieldBegin + nameField.size(),
44 nameField.data(), parsedQueryName.data(), parsedQueryName.size());
51 std::vector<char> parsedQueryName(outputBufferSize, 0);
52 const uint8_t *nameFieldBegin = nameField.data();
54 &nameFieldBegin, nameFieldBegin + nameField.size(),
55 nameField.data(), parsedQueryName.data(), parsedQueryName.size());
67 std::vector<char> parsedQueryName(outputBufferSize, 0);
68 const uint8_t *nameFieldBegin = nameField.data();
70 &nameFieldBegin, nameFieldBegin + nameField.size(), nameField.data(),
71 parsedQueryName.data(), parsedQueryName.size());
100 std::string maxLengthQName = maxLengthLabel +
'.' + maxLengthLabel +
'.' +
101 maxLengthLabel +
'.' + maxLengthLabel;
106 std::string overSizedQName = maxLengthQName;
109 overSizedQName.insert(overSizedQName.end() - 3,
'.');
113 2 * overSizedQName.size());
116BOOST_AUTO_TEST_SUITE_END()
ParseNameStatus parse_name(const uint8_t **inpos, const uint8_t *inend, const uint8_t *inbuf, char *buf, size_t bufsize)
constexpr int MAX_LABEL_LENGTH
constexpr int MAX_QUERY_NAME_LENGTH
constexpr int MAX_QUERY_NAME_BUFFER_LENGTH
static std::vector< uint8_t > CreateDNSQuestionNameField(const std::string &queryName)
Implement std::hash so RCUPtr can be used as a key for maps or sets.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::ostream & operator<<(std::ostream &os, const ParseNameStatus &status)
static void CheckParseName(const std::string &queryName)
BOOST_AUTO_TEST_CASE(parse_name_simple_tests)
static void CheckParseNameError(const std::string &queryName, const ParseNameStatus expectedError, const size_t &outputBufferSize=MAX_QUERY_NAME_BUFFER_LENGTH)
constexpr std::underlying_type< E >::type to_integral(E e)