OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/dns/record_rdata.h" | 5 #include "net/dns/record_rdata.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "net/dns/dns_response.h" | 9 #include "net/dns/dns_response.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 EXPECT_FALSE(record_obj->GetBit(0)); | 189 EXPECT_FALSE(record_obj->GetBit(0)); |
190 EXPECT_TRUE(record_obj->GetBit(1)); | 190 EXPECT_TRUE(record_obj->GetBit(1)); |
191 for (int i = 2; i < 15; i++) { | 191 for (int i = 2; i < 15; i++) { |
192 EXPECT_FALSE(record_obj->GetBit(i)); | 192 EXPECT_FALSE(record_obj->GetBit(i)); |
193 } | 193 } |
194 EXPECT_TRUE(record_obj->GetBit(15)); | 194 EXPECT_TRUE(record_obj->GetBit(15)); |
195 | 195 |
196 ASSERT_TRUE(record_obj->IsEqual(record_obj.get())); | 196 ASSERT_TRUE(record_obj->IsEqual(record_obj.get())); |
197 } | 197 } |
198 | 198 |
199 TEST(RecordRdataTest, CreateNsecRecordWithEmptyBitmapReturnsNull) { | |
200 std::unique_ptr<NsecRecordRdata> record_obj; | |
Ryan Sleevi
2016/07/06 17:48:25
STYLE: Keep this scoped closer to where it's used
| |
201 | |
202 // These are just the rdata portions of the DNS records, rather than complete | |
203 // records, but it works well enough for this test. | |
204 // This record has a bitmap that is 0 bytes long. | |
205 const uint8_t record[] = {0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', | |
206 'l', 'e', 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x00}; | |
207 | |
208 DnsRecordParser parser(record, sizeof(record), 0); | |
209 base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); | |
210 | |
211 record_obj = NsecRecordRdata::Create(record_strpiece, parser); | |
212 ASSERT_EQ(nullptr, record_obj); | |
Ryan Sleevi
2016/07/06 17:48:25
ASSERT_FALSE(record_obj)
| |
213 } | |
214 | |
215 TEST(RecordRdataTest, CreateNsecRecordWithOversizedBitmapReturnsNull) { | |
216 std::unique_ptr<NsecRecordRdata> record_obj; | |
217 | |
218 // These are just the rdata portions of the DNS records, rather than complete | |
219 // records, but it works well enough for this test. | |
220 // This record has a bitmap that is 33 bytes long. The maximum size allowed by | |
221 // RFC 3845, Section 2.1.2, is 32 bytes. | |
222 const uint8_t record[] = { | |
223 0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', 'l', 'e', | |
224 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, | |
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | |
228 | |
229 DnsRecordParser parser(record, sizeof(record), 0); | |
230 base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); | |
231 | |
232 record_obj = NsecRecordRdata::Create(record_strpiece, parser); | |
233 ASSERT_EQ(nullptr, record_obj); | |
Ryan Sleevi
2016/07/06 17:48:25
ASSERT_FALSE(record_obj)
| |
234 } | |
199 | 235 |
200 } // namespace net | 236 } // namespace net |
OLD | NEW |