mirror of
https://github.com/mfontanini/libtins
synced 2026-01-28 12:44:25 +01:00
Refactored DNS and UDP class.
This commit is contained in:
@@ -39,6 +39,7 @@ void DNSTest::test_equals(const DNS &dns1, const DNS &dns2) {
|
||||
EXPECT_EQ(dns1.additional(), dns2.additional());
|
||||
EXPECT_EQ(dns1.pdu_type(), dns2.pdu_type());
|
||||
EXPECT_EQ(dns1.header_size(), dns2.header_size());
|
||||
EXPECT_EQ(bool(dns1.inner_pdu()), bool(dns2.inner_pdu()));
|
||||
}
|
||||
|
||||
void DNSTest::test_equals(const DNS::Query &q1, const DNS::Query &q2) {
|
||||
@@ -79,6 +80,27 @@ TEST_F(DNSTest, ConstructorFromBuffer) {
|
||||
test_equals(answers.front(), DNS::Resource("www.example.com", "192.168.0.1", DNS::A, DNS::IN, 0x1234));
|
||||
}
|
||||
|
||||
TEST_F(DNSTest, CopyConstructor) {
|
||||
DNS dns1(expected_packet, sizeof(expected_packet));
|
||||
DNS dns2(dns1);
|
||||
test_equals(dns1, dns2);
|
||||
}
|
||||
|
||||
TEST_F(DNSTest, CopyAssignmentOperator) {
|
||||
DNS dns1(expected_packet, sizeof(expected_packet));
|
||||
DNS dns2;
|
||||
dns2 = dns1;
|
||||
test_equals(dns1, dns2);
|
||||
}
|
||||
|
||||
TEST_F(DNSTest, NestedCopy) {
|
||||
DNS *nested = new DNS(expected_packet, sizeof(expected_packet));
|
||||
DNS dns1(expected_packet, sizeof(expected_packet));
|
||||
dns1.inner_pdu(nested);
|
||||
DNS dns2(dns1);
|
||||
test_equals(dns1, dns2);
|
||||
}
|
||||
|
||||
TEST_F(DNSTest, ID) {
|
||||
DNS dns;
|
||||
dns.id(0x7263);
|
||||
|
||||
Reference in New Issue
Block a user