@@ -38,6 +38,40 @@ TEST_F(LibraryTest, ParseTxtReplyOK) {
38
38
ares_free_data (txt);
39
39
}
40
40
41
+ TEST_F (LibraryTest, ParseTxtExtReplyOK) {
42
+ DNSPacket pkt;
43
+ std::string expected1 = " txt1.example.com" ;
44
+ std::string expected2a = " txt2a" ;
45
+ std::string expected2b (" ABC\0 ABC" , 7 );
46
+ pkt.set_qid (0x1234 ).set_response ().set_aa ()
47
+ .add_question (new DNSQuestion (" example.com" , ns_t_mx))
48
+ .add_answer (new DNSTxtRR (" example.com" , 100 , {expected1}))
49
+ .add_answer (new DNSTxtRR (" example.com" , 100 , {expected2a, expected2b}));
50
+ std::vector<byte> data = pkt.data ();
51
+
52
+ struct ares_txt_ext * txt = nullptr ;
53
+ EXPECT_EQ (ARES_SUCCESS, ares_parse_txt_reply_ext (data.data (), data.size (), &txt));
54
+ ASSERT_NE (nullptr , txt);
55
+ EXPECT_EQ (std::vector<byte>(expected1.data (), expected1.data () + expected1.size ()),
56
+ std::vector<byte>(txt->txt , txt->txt + txt->length ));
57
+ EXPECT_EQ (1 , txt->record_start );
58
+
59
+ struct ares_txt_ext * txt2 = txt->next ;
60
+ ASSERT_NE (nullptr , txt2);
61
+ EXPECT_EQ (std::vector<byte>(expected2a.data (), expected2a.data () + expected2a.size ()),
62
+ std::vector<byte>(txt2->txt , txt2->txt + txt2->length ));
63
+ EXPECT_EQ (1 , txt2->record_start );
64
+
65
+ struct ares_txt_ext * txt3 = txt2->next ;
66
+ ASSERT_NE (nullptr , txt3);
67
+ EXPECT_EQ (std::vector<byte>(expected2b.data (), expected2b.data () + expected2b.size ()),
68
+ std::vector<byte>(txt3->txt , txt3->txt + txt3->length ));
69
+ EXPECT_EQ (nullptr , txt3->next );
70
+ EXPECT_EQ (0 , txt3->record_start );
71
+
72
+ ares_free_data (txt);
73
+ }
74
+
41
75
TEST_F (LibraryTest, ParseTxtMalformedReply1) {
42
76
std::vector<byte> data = {
43
77
0x12 , 0x34 , // qid
0 commit comments