|
@@ -8,7 +8,7 @@
|
8
|
8
|
|
9
|
9
|
#include "dns/QDnsLabel.h"
|
10
|
10
|
|
11
|
|
-struct DnsLabelTestParams
|
|
11
|
+struct DnsLabelParseTestParams
|
12
|
12
|
{
|
13
|
13
|
bool isValid;
|
14
|
14
|
const char* hexData;
|
|
@@ -16,11 +16,11 @@ struct DnsLabelTestParams
|
16
|
16
|
const char* label;
|
17
|
17
|
};
|
18
|
18
|
|
19
|
|
-class DnsLabelTest : public ::testing::TestWithParam<DnsLabelTestParams>
|
|
19
|
+class DnsLabelParseTest : public ::testing::TestWithParam<DnsLabelParseTestParams>
|
20
|
20
|
{
|
21
|
21
|
};
|
22
|
22
|
|
23
|
|
-TEST_P(DnsLabelTest, parse)
|
|
23
|
+TEST_P(DnsLabelParseTest, parse)
|
24
|
24
|
{
|
25
|
25
|
auto params = GetParam();
|
26
|
26
|
auto data = QByteArray::fromHex(params.hexData);
|
|
@@ -36,51 +36,80 @@ TEST_P(DnsLabelTest, parse)
|
36
|
36
|
}
|
37
|
37
|
}
|
38
|
38
|
|
39
|
|
-INSTANTIATE_TEST_CASE_P(DnsLabelTestInst,
|
40
|
|
- DnsLabelTest,
|
|
39
|
+INSTANTIATE_TEST_CASE_P(DnsLabelParseTestInst,
|
|
40
|
+ DnsLabelParseTest,
|
41
|
41
|
::testing::Values(
|
42
|
|
- DnsLabelTestParams {false, "", 0},
|
43
|
|
- DnsLabelTestParams {true, "00", 0, ""},
|
44
|
|
- DnsLabelTestParams {true,
|
|
42
|
+ DnsLabelParseTestParams {false, "", 0},
|
|
43
|
+ DnsLabelParseTestParams {true, "00", 0, ""},
|
|
44
|
+ DnsLabelParseTestParams {true,
|
45
|
45
|
"06676f6f676c6502667200",
|
46
|
46
|
0,
|
47
|
47
|
"google.fr"
|
48
|
48
|
},
|
49
|
|
- DnsLabelTestParams {true,
|
|
49
|
+ DnsLabelParseTestParams {true,
|
50
|
50
|
"587a8180000100010000000006676f6f676c650266720000010001c00c000100010000012c0004acd912a3",
|
51
|
51
|
12,
|
52
|
52
|
"google.fr"
|
53
|
53
|
},
|
54
|
|
- DnsLabelTestParams {true,
|
|
54
|
+ DnsLabelParseTestParams {true,
|
55
|
55
|
"587a8180000100010000000006676f6f676c650266720000010001c00c000100010000012c0004acd912a3",
|
56
|
56
|
27,
|
57
|
57
|
"google.fr"
|
58
|
58
|
},
|
59
|
|
- DnsLabelTestParams {true,
|
|
59
|
+ DnsLabelParseTestParams {true,
|
60
|
60
|
"3dcd8580000100020000000003777777067274686f6e6903636f6d0000010001c00c00050001000002580008057365727633c010c02c00010001000002580004d5f6343d",
|
61
|
61
|
12,
|
62
|
62
|
"www.rthoni.com"
|
63
|
63
|
},
|
64
|
|
- DnsLabelTestParams {true,
|
|
64
|
+ DnsLabelParseTestParams {true,
|
65
|
65
|
"3dcd8580000100020000000003777777067274686f6e6903636f6d0000010001c00c00050001000002580008057365727633c010c02c00010001000002580004d5f6343d",
|
66
|
66
|
32,
|
67
|
67
|
"www.rthoni.com"
|
68
|
68
|
},
|
69
|
|
- DnsLabelTestParams {true,
|
|
69
|
+ DnsLabelParseTestParams {true,
|
70
|
70
|
"3dcd8580000100020000000003777777067274686f6e6903636f6d0000010001c00c00050001000002580008057365727633c010c02c00010001000002580004d5f6343d",
|
71
|
71
|
44,
|
72
|
72
|
"serv3.rthoni.com"
|
73
|
73
|
},
|
74
|
|
- DnsLabelTestParams {false,
|
|
74
|
+ DnsLabelParseTestParams {false,
|
75
|
75
|
"3dcd8580000100020000000003777777067274686f6e6903636f6d0000010001c00c00050001000002580008057365727633 c02c c02c00010001000002580004d5f6343d",
|
76
|
76
|
44
|
77
|
77
|
},
|
78
|
|
- DnsLabelTestParams {false,
|
|
78
|
+ DnsLabelParseTestParams {false,
|
79
|
79
|
"3dcd8580000100020000000003777777067274686f6e6903636f6d0000010001c00c00050001000002580008057365727633 802c c02c00010001000002580004d5f6343d",
|
80
|
80
|
44
|
81
|
81
|
},
|
82
|
|
- DnsLabelTestParams {false,
|
|
82
|
+ DnsLabelParseTestParams {false,
|
83
|
83
|
"3dcd8580000100020000000003777777067274686f6e6903636f6d0000010001c00c00050001000002580008057365727633 402c c02c00010001000002580004d5f6343d",
|
84
|
84
|
44
|
85
|
85
|
}
|
86
|
86
|
));
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+struct DnsLabelSerializeTestParams
|
|
90
|
+{
|
|
91
|
+ const char* label;
|
|
92
|
+ const char* hexData;
|
|
93
|
+};
|
|
94
|
+
|
|
95
|
+class DnsLabelSerializeTest : public ::testing::TestWithParam<DnsLabelSerializeTestParams>
|
|
96
|
+{
|
|
97
|
+};
|
|
98
|
+
|
|
99
|
+TEST_P(DnsLabelSerializeTest, parse)
|
|
100
|
+{
|
|
101
|
+ auto params = GetParam();
|
|
102
|
+ auto label = QDns::QDnsLabel::serialize(params.label);
|
|
103
|
+ auto data = QByteArray::fromHex(params.hexData);
|
|
104
|
+ ASSERT_EQ(label, data);
|
|
105
|
+}
|
|
106
|
+
|
|
107
|
+INSTANTIATE_TEST_CASE_P(DnsLabelSerializeTestInst,
|
|
108
|
+ DnsLabelSerializeTest,
|
|
109
|
+ ::testing::Values(
|
|
110
|
+ DnsLabelSerializeTestParams {"", "00"},
|
|
111
|
+ DnsLabelSerializeTestParams {"com", "03636f6d00"},
|
|
112
|
+ DnsLabelSerializeTestParams {"fr", "02667200"},
|
|
113
|
+ DnsLabelSerializeTestParams {"google.fr", "06676f6f676c6502667200"},
|
|
114
|
+ DnsLabelSerializeTestParams {"www.rthoni.com", "03777777067274686f6e6903636f6d00"}
|
|
115
|
+ ));
|