ares-test-parse.cc (c-ares-1.17.1) | : | ares-test-parse.cc (c-ares-1.17.2) | ||
---|---|---|---|---|
skipping to change at line 13 | skipping to change at line 13 | |||
#include <sstream> | #include <sstream> | |||
#include <vector> | #include <vector> | |||
namespace ares { | namespace ares { | |||
namespace test { | namespace test { | |||
TEST_F(LibraryTest, ParseRootName) { | TEST_F(LibraryTest, ParseRootName) { | |||
DNSPacket pkt; | DNSPacket pkt; | |||
pkt.set_qid(0x1234).set_response().set_aa() | pkt.set_qid(0x1234).set_response().set_aa() | |||
.add_question(new DNSQuestion(".", ns_t_a)) | .add_question(new DNSQuestion(".", T_A)) | |||
.add_answer(new DNSARR(".", 100, {0x02, 0x03, 0x04, 0x05})); | .add_answer(new DNSARR(".", 100, {0x02, 0x03, 0x04, 0x05})); | |||
std::vector<byte> data = pkt.data(); | std::vector<byte> data = pkt.data(); | |||
struct hostent *host = nullptr; | struct hostent *host = nullptr; | |||
struct ares_addrttl info[2]; | struct ares_addrttl info[2]; | |||
int count = 2; | int count = 2; | |||
EXPECT_EQ(ARES_SUCCESS, ares_parse_a_reply(data.data(), data.size(), | EXPECT_EQ(ARES_SUCCESS, ares_parse_a_reply(data.data(), data.size(), | |||
&host, info, &count)); | &host, info, &count)); | |||
EXPECT_EQ(1, count); | EXPECT_EQ(1, count); | |||
std::stringstream ss; | std::stringstream ss; | |||
skipping to change at line 63 | skipping to change at line 63 | |||
int count = 2; | int count = 2; | |||
EXPECT_EQ(ARES_SUCCESS, ares_parse_a_reply(data.data(), data.size(), | EXPECT_EQ(ARES_SUCCESS, ares_parse_a_reply(data.data(), data.size(), | |||
&host, info, &count)); | &host, info, &count)); | |||
EXPECT_EQ(1, count); | EXPECT_EQ(1, count); | |||
std::stringstream ss; | std::stringstream ss; | |||
ss << HostEnt(host); | ss << HostEnt(host); | |||
EXPECT_EQ("{'' aliases=[] addrs=[2.3.4.5]}", ss.str()); | EXPECT_EQ("{'' aliases=[] addrs=[2.3.4.5]}", ss.str()); | |||
ares_free_hostent(host); | ares_free_hostent(host); | |||
} | } | |||
#if 0 /* We are validating hostnames now, its not clear how this would ever be v alid */ | ||||
TEST_F(LibraryTest, ParseEscapedName) { | TEST_F(LibraryTest, ParseEscapedName) { | |||
std::vector<byte> data = { | std::vector<byte> data = { | |||
0x12, 0x34, // qid | 0x12, 0x34, // qid | |||
0x84, // response + query + AA + not-TC + not-RD | 0x84, // response + query + AA + not-TC + not-RD | |||
0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError | 0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError | |||
0x00, 0x01, // num questions | 0x00, 0x01, // num questions | |||
0x00, 0x01, // num answer RRs | 0x00, 0x01, // num answer RRs | |||
0x00, 0x00, // num authority RRs | 0x00, 0x00, // num authority RRs | |||
0x00, 0x00, // num additional RRs | 0x00, 0x00, // num additional RRs | |||
// Question | // Question | |||
skipping to change at line 108 | skipping to change at line 109 | |||
EXPECT_EQ(11, hent.name_.size()); | EXPECT_EQ(11, hent.name_.size()); | |||
EXPECT_EQ('a', hent.name_[0]); | EXPECT_EQ('a', hent.name_[0]); | |||
EXPECT_EQ('\\', hent.name_[1]); | EXPECT_EQ('\\', hent.name_[1]); | |||
EXPECT_EQ('\\', hent.name_[2]); | EXPECT_EQ('\\', hent.name_[2]); | |||
EXPECT_EQ('b', hent.name_[3]); | EXPECT_EQ('b', hent.name_[3]); | |||
EXPECT_EQ('\\', hent.name_[4]); | EXPECT_EQ('\\', hent.name_[4]); | |||
EXPECT_EQ('.', hent.name_[5]); | EXPECT_EQ('.', hent.name_[5]); | |||
EXPECT_EQ('c', hent.name_[6]); | EXPECT_EQ('c', hent.name_[6]); | |||
ares_free_hostent(host); | ares_free_hostent(host); | |||
} | } | |||
#endif | ||||
TEST_F(LibraryTest, ParsePartialCompressedName) { | TEST_F(LibraryTest, ParsePartialCompressedName) { | |||
std::vector<byte> data = { | std::vector<byte> data = { | |||
0x12, 0x34, // qid | 0x12, 0x34, // qid | |||
0x84, // response + query + AA + not-TC + not-RD | 0x84, // response + query + AA + not-TC + not-RD | |||
0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError | 0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError | |||
0x00, 0x01, // num questions | 0x00, 0x01, // num questions | |||
0x00, 0x01, // num answer RRs | 0x00, 0x01, // num answer RRs | |||
0x00, 0x00, // num authority RRs | 0x00, 0x00, // num authority RRs | |||
0x00, 0x00, // num additional RRs | 0x00, 0x00, // num additional RRs | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 3 lines changed or added |