|
@@ -8,7 +8,7 @@
|
8
|
8
|
|
9
|
9
|
#include "dns/QDnsQuery.h"
|
10
|
10
|
|
11
|
|
-struct DnsQueryTestParams
|
|
11
|
+struct DnsQueryParseTestParams
|
12
|
12
|
{
|
13
|
13
|
bool isValid;
|
14
|
14
|
const char* hexData;
|
|
@@ -18,11 +18,11 @@ struct DnsQueryTestParams
|
18
|
18
|
quint16 clazz;
|
19
|
19
|
};
|
20
|
20
|
|
21
|
|
-class DnsQueryTest : public ::testing::TestWithParam<DnsQueryTestParams>
|
|
21
|
+class DnsQueryParseTest : public ::testing::TestWithParam<DnsQueryParseTestParams>
|
22
|
22
|
{
|
23
|
23
|
};
|
24
|
24
|
|
25
|
|
-TEST_P(DnsQueryTest, parse)
|
|
25
|
+TEST_P(DnsQueryParseTest, parse)
|
26
|
26
|
{
|
27
|
27
|
auto params = GetParam();
|
28
|
28
|
auto data = QByteArray::fromHex(params.hexData);
|
|
@@ -38,26 +38,26 @@ TEST_P(DnsQueryTest, parse)
|
38
|
38
|
}
|
39
|
39
|
}
|
40
|
40
|
|
41
|
|
-INSTANTIATE_TEST_CASE_P(DnsQueryTestInst,
|
42
|
|
- DnsQueryTest,
|
|
41
|
+INSTANTIATE_TEST_CASE_P(DnsQueryParseTestInst,
|
|
42
|
+ DnsQueryParseTest,
|
43
|
43
|
::testing::Values(
|
44
|
|
- DnsQueryTestParams {false, "", 0},
|
45
|
|
- DnsQueryTestParams {false, "00", 0},
|
46
|
|
- DnsQueryTestParams {true,
|
|
44
|
+ DnsQueryParseTestParams {false, "", 0},
|
|
45
|
+ DnsQueryParseTestParams {false, "00", 0},
|
|
46
|
+ DnsQueryParseTestParams {true,
|
47
|
47
|
"0377777706676f6f676c650266720000010001",
|
48
|
48
|
0,
|
49
|
49
|
"www.google.fr",
|
50
|
50
|
1,
|
51
|
51
|
1
|
52
|
52
|
},
|
53
|
|
- DnsQueryTestParams {true,
|
|
53
|
+ DnsQueryParseTestParams {true,
|
54
|
54
|
"03777777067274686f6e6903636f6d0000030008",
|
55
|
55
|
0,
|
56
|
56
|
"www.rthoni.com",
|
57
|
57
|
3,
|
58
|
58
|
8
|
59
|
59
|
},
|
60
|
|
- DnsQueryTestParams {true,
|
|
60
|
+ DnsQueryParseTestParams {true,
|
61
|
61
|
"0003777777067274686f6e6903636f6d0000030008",
|
62
|
62
|
1,
|
63
|
63
|
"www.rthoni.com",
|
|
@@ -65,3 +65,51 @@ INSTANTIATE_TEST_CASE_P(DnsQueryTestInst,
|
65
|
65
|
8
|
66
|
66
|
}
|
67
|
67
|
));
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+struct DnsQuerySerializeTestParams
|
|
72
|
+{
|
|
73
|
+ const char* hexData;
|
|
74
|
+
|
|
75
|
+ const char* name;
|
|
76
|
+ quint16 type;
|
|
77
|
+ quint16 clazz;
|
|
78
|
+};
|
|
79
|
+
|
|
80
|
+class DnsQuerySerializeTest : public ::testing::TestWithParam<DnsQuerySerializeTestParams>
|
|
81
|
+{
|
|
82
|
+};
|
|
83
|
+
|
|
84
|
+TEST_P(DnsQuerySerializeTest, serialize)
|
|
85
|
+{
|
|
86
|
+ auto params = GetParam();
|
|
87
|
+ auto data = QByteArray::fromHex(params.hexData);
|
|
88
|
+ QDns::QDnsQuery query;
|
|
89
|
+
|
|
90
|
+ query.setName(params.name);
|
|
91
|
+ query.setType(params.type);
|
|
92
|
+ query.setClass(params.clazz);
|
|
93
|
+
|
|
94
|
+ ASSERT_EQ(query.serialize().toHex(), QString(params.hexData).remove(" "));
|
|
95
|
+}
|
|
96
|
+
|
|
97
|
+INSTANTIATE_TEST_CASE_P(DnsQuerySerializeTestInst,
|
|
98
|
+ DnsQuerySerializeTest,
|
|
99
|
+ ::testing::Values(
|
|
100
|
+ DnsQuerySerializeTestParams {"0266720000020008",
|
|
101
|
+ "fr",
|
|
102
|
+ 2,
|
|
103
|
+ 8
|
|
104
|
+ },
|
|
105
|
+ DnsQuerySerializeTestParams {"06676f6f676c650266720000010001",
|
|
106
|
+ "google.fr",
|
|
107
|
+ 1,
|
|
108
|
+ 1
|
|
109
|
+ },
|
|
110
|
+ DnsQuerySerializeTestParams {"03777777067274686f6e6903636f6d0000010001",
|
|
111
|
+ "www.rthoni.com",
|
|
112
|
+ 1,
|
|
113
|
+ 1
|
|
114
|
+ }
|
|
115
|
+ ));
|