Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: net/dns/record_rdata_unittest.cc

Issue 17143006: Limited NSEC support to RecordParsed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_transaction_cleanup
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/record_rdata.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "net/base/net_util.h" 6 #include "net/base/net_util.h"
7 #include "net/dns/dns_response.h" 7 #include "net/dns/dns_response.h"
8 #include "net/dns/record_rdata.h" 8 #include "net/dns/record_rdata.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 std::vector<std::string> expected; 173 std::vector<std::string> expected;
174 expected.push_back("www"); 174 expected.push_back("www");
175 expected.push_back("google"); 175 expected.push_back("google");
176 expected.push_back("com"); 176 expected.push_back("com");
177 177
178 ASSERT_EQ(expected, record_obj->texts()); 178 ASSERT_EQ(expected, record_obj->texts());
179 179
180 ASSERT_TRUE(record_obj->IsEqual(record_obj.get())); 180 ASSERT_TRUE(record_obj->IsEqual(record_obj.get()));
181 } 181 }
182 182
183 TEST(RecordRdataTest, ParseNsecRecord) {
184 scoped_ptr<NsecRecordRdata> record_obj;
185
186 // These are just the rdata portions of the DNS records, rather than complete
187 // records, but it works well enough for this test.
188
189 const char record[] = {
190 0x03, 'w', 'w', 'w',
191 0x06, 'g', 'o', 'o', 'g', 'l', 'e',
192 0x03, 'c', 'o', 'm',
193 0x00,
194 0x00, 0x02, 0x40, 0x01
195 };
196
197 DnsRecordParser parser(record, sizeof(record), 0);
198 base::StringPiece record_strpiece(record, sizeof(record));
199
200 record_obj = NsecRecordRdata::Create(record_strpiece, parser);
201 ASSERT_TRUE(record_obj != NULL);
202
203 ASSERT_EQ(16u, record_obj->bitmap_length());
204
205 EXPECT_FALSE(record_obj->GetBit(0));
206 EXPECT_TRUE(record_obj->GetBit(1));
207 for (int i = 2; i < 15; i++) {
208 EXPECT_FALSE(record_obj->GetBit(i));
209 }
210 EXPECT_TRUE(record_obj->GetBit(15));
211
212 ASSERT_TRUE(record_obj->IsEqual(record_obj.get()));
213 }
214
215
183 } // namespace net 216 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/record_rdata.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698