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

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

Issue 21534003: avoid char+'\xHH' as it's too easy to use values > 127 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: corresponding change in chrome unit tests Created 7 years, 4 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/mock_mdns_socket_factory.cc ('k') | net/dns/record_rdata_unittest.cc » ('j') | 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 "net/dns/record_parsed.h" 5 #include "net/dns/record_parsed.h"
6 6
7 #include "net/dns/dns_protocol.h" 7 #include "net/dns/dns_protocol.h"
8 #include "net/dns/dns_response.h" 8 #include "net/dns/dns_response.h"
9 #include "net/dns/dns_test_util.h" 9 #include "net/dns/dns_test_util.h"
10 #include "net/dns/record_rdata.h" 10 #include "net/dns/record_rdata.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 static const char kT1ResponseWithCacheFlushBit[] = { 15 static const uint8 kT1ResponseWithCacheFlushBit[] = {
16 '\x0a', 'c', 'o', 'd', 'e', 'r', 'e', 'v', 'i', 'e', 'w', 16 0x0a, 'c', 'o', 'd', 'e', 'r', 'e', 'v', 'i', 'e', 'w',
17 '\x08', 'c', 'h', 'r', 'o', 'm', 'i', 'u', 'm', 17 0x08, 'c', 'h', 'r', 'o', 'm', 'i', 'u', 'm',
18 '\x03', 'o', 'r', 'g', 18 0x03, 'o', 'r', 'g',
19 '\x00', 19 0x00,
20 '\x00', '\x05', // TYPE is CNAME. 20 0x00, 0x05, // TYPE is CNAME.
21 '\x80', '\x01', // CLASS is IN with cache flush bit set. 21 0x80, 0x01, // CLASS is IN with cache flush bit set.
22 '\x00', '\x01', // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds. 22 0x00, 0x01, // TTL (4 bytes) is 20 hours, 47 minutes, 48 seconds.
23 '\x24', '\x74', 23 0x24, 0x74,
24 '\x00', '\x12', // RDLENGTH is 18 bytes. 24 0x00, 0x12, // RDLENGTH is 18 bytes.
25 // ghs.l.google.com in DNS format. 25 // ghs.l.google.com in DNS format.
26 '\x03', 'g', 'h', 's', 26 0x03, 'g', 'h', 's',
27 '\x01', 'l', 27 0x01, 'l',
28 '\x06', 'g', 'o', 'o', 'g', 'l', 'e', 28 0x06, 'g', 'o', 'o', 'g', 'l', 'e',
29 '\x03', 'c', 'o', 'm', 29 0x03, 'c', 'o', 'm',
30 '\x00' 30 0x00
31 }; 31 };
32 32
33 TEST(RecordParsedTest, ParseSingleRecord) { 33 TEST(RecordParsedTest, ParseSingleRecord) {
34 DnsRecordParser parser(kT1ResponseDatagram, sizeof(kT1ResponseDatagram), 34 DnsRecordParser parser(kT1ResponseDatagram, sizeof(kT1ResponseDatagram),
35 sizeof(dns_protocol::Header)); 35 sizeof(dns_protocol::Header));
36 scoped_ptr<const RecordParsed> record; 36 scoped_ptr<const RecordParsed> record;
37 const CnameRecordRdata* rdata; 37 const CnameRecordRdata* rdata;
38 38
39 parser.SkipQuestion(); 39 parser.SkipQuestion();
40 record = RecordParsed::CreateFrom(&parser, base::Time()); 40 record = RecordParsed::CreateFrom(&parser, base::Time());
(...skipping 25 matching lines...) Expand all
66 scoped_ptr<const RecordParsed> record2 = 66 scoped_ptr<const RecordParsed> record2 =
67 RecordParsed::CreateFrom(&parser2, base::Time()); 67 RecordParsed::CreateFrom(&parser2, base::Time());
68 68
69 EXPECT_FALSE(record1->IsEqual(record2.get(), false)); 69 EXPECT_FALSE(record1->IsEqual(record2.get(), false));
70 EXPECT_TRUE(record1->IsEqual(record2.get(), true)); 70 EXPECT_TRUE(record1->IsEqual(record2.get(), true));
71 EXPECT_FALSE(record2->IsEqual(record1.get(), false)); 71 EXPECT_FALSE(record2->IsEqual(record1.get(), false));
72 EXPECT_TRUE(record2->IsEqual(record1.get(), true)); 72 EXPECT_TRUE(record2->IsEqual(record1.get(), true));
73 } 73 }
74 74
75 } //namespace net 75 } //namespace net
OLDNEW
« no previous file with comments | « net/dns/mock_mdns_socket_factory.cc ('k') | net/dns/record_rdata_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698