|
@@ -1,5 +1,6 @@
|
1
|
1
|
#include <gtest/gtest.h>
|
2
|
|
-#include <QtCore/QByteArray>
|
|
2
|
+#include <QByteArray>
|
|
3
|
+#include <QString>
|
3
|
4
|
|
4
|
5
|
#include "dns/QDnsHeader.h"
|
5
|
6
|
|
|
@@ -57,12 +58,24 @@ TEST_P(DNSHeaderTest, parseAndGetters)
|
57
|
58
|
ASSERT_EQ(header.getAnswerCount(), params.answerCount);
|
58
|
59
|
ASSERT_EQ(header.getAuthorityCount(), params.authorityCount);
|
59
|
60
|
ASSERT_EQ(header.getAdditionalCount(), params.additionalCount);
|
|
61
|
+
|
|
62
|
+ ASSERT_EQ(header.serialize().toHex(), QString(params.hexData).remove(" "));
|
|
63
|
+ }
|
|
64
|
+ else
|
|
65
|
+ {
|
|
66
|
+ ASSERT_EQ(header.serialize().size(), 0);
|
60
|
67
|
}
|
61
|
68
|
}
|
62
|
69
|
|
63
|
70
|
TEST_P(DNSHeaderTest, settersAndGetters1)
|
64
|
71
|
{
|
65
|
72
|
auto params = GetParam();
|
|
73
|
+
|
|
74
|
+ if (!params.isValid)
|
|
75
|
+ {
|
|
76
|
+ return;
|
|
77
|
+ }
|
|
78
|
+
|
66
|
79
|
auto data = QByteArray::fromHex(params.hexData);
|
67
|
80
|
QDNS::QDnsHeader header;
|
68
|
81
|
|
|
@@ -90,11 +103,19 @@ TEST_P(DNSHeaderTest, settersAndGetters1)
|
90
|
103
|
ASSERT_EQ(header.getAnswerCount(), params.answerCount);
|
91
|
104
|
ASSERT_EQ(header.getAuthorityCount(), params.authorityCount);
|
92
|
105
|
ASSERT_EQ(header.getAdditionalCount(), params.additionalCount);
|
|
106
|
+
|
|
107
|
+ ASSERT_EQ(header.serialize().toHex(), QString(params.hexData).remove(" "));
|
93
|
108
|
}
|
94
|
109
|
|
95
|
110
|
TEST_P(DNSHeaderTest, settersAndGetters2)
|
96
|
111
|
{
|
97
|
112
|
auto params = GetParam();
|
|
113
|
+
|
|
114
|
+ if (!params.isValid)
|
|
115
|
+ {
|
|
116
|
+ return;
|
|
117
|
+ }
|
|
118
|
+
|
98
|
119
|
auto data = QByteArray::fromHex(params.hexData);
|
99
|
120
|
QDNS::QDnsHeader header;
|
100
|
121
|
|
|
@@ -131,6 +152,8 @@ TEST_P(DNSHeaderTest, settersAndGetters2)
|
131
|
152
|
ASSERT_EQ(header.getAnswerCount(), params.answerCount);
|
132
|
153
|
ASSERT_EQ(header.getAuthorityCount(), params.authorityCount);
|
133
|
154
|
ASSERT_EQ(header.getAdditionalCount(), params.additionalCount);
|
|
155
|
+
|
|
156
|
+ ASSERT_EQ(header.serialize().toHex(), QString(params.hexData).remove(" "));
|
134
|
157
|
}
|
135
|
158
|
|
136
|
159
|
INSTANTIATE_TEST_CASE_P(DNSHeaderTestInst,
|