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

Unified Diff: net/dns/record_rdata_unittest.cc

Issue 2118383006: Fix "conversion of size_t to unsigned int" warning (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses comments from Ryan Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/record_rdata.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/record_rdata_unittest.cc
diff --git a/net/dns/record_rdata_unittest.cc b/net/dns/record_rdata_unittest.cc
index c41e39aa5e6f3d186a69036a79d2a096e2345596..f26808cfa9e63bb578dbb84d564c8ae7446051e7 100644
--- a/net/dns/record_rdata_unittest.cc
+++ b/net/dns/record_rdata_unittest.cc
@@ -196,5 +196,41 @@ TEST(RecordRdataTest, ParseNsecRecord) {
ASSERT_TRUE(record_obj->IsEqual(record_obj.get()));
}
+TEST(RecordRdataTest, CreateNsecRecordWithEmptyBitmapReturnsNull) {
+ std::unique_ptr<NsecRecordRdata> record_obj;
Ryan Sleevi 2016/07/06 17:48:25 STYLE: Keep this scoped closer to where it's used
+
+ // These are just the rdata portions of the DNS records, rather than complete
+ // records, but it works well enough for this test.
+ // This record has a bitmap that is 0 bytes long.
+ const uint8_t record[] = {0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g',
+ 'l', 'e', 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x00};
+
+ DnsRecordParser parser(record, sizeof(record), 0);
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record));
+
+ record_obj = NsecRecordRdata::Create(record_strpiece, parser);
+ ASSERT_EQ(nullptr, record_obj);
Ryan Sleevi 2016/07/06 17:48:25 ASSERT_FALSE(record_obj)
+}
+
+TEST(RecordRdataTest, CreateNsecRecordWithOversizedBitmapReturnsNull) {
+ std::unique_ptr<NsecRecordRdata> record_obj;
+
+ // These are just the rdata portions of the DNS records, rather than complete
+ // records, but it works well enough for this test.
+ // This record has a bitmap that is 33 bytes long. The maximum size allowed by
+ // RFC 3845, Section 2.1.2, is 32 bytes.
+ const uint8_t record[] = {
+ 0x03, 'w', 'w', 'w', 0x06, 'g', 'o', 'o', 'g', 'l', 'e',
+ 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ DnsRecordParser parser(record, sizeof(record), 0);
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record));
+
+ record_obj = NsecRecordRdata::Create(record_strpiece, parser);
+ ASSERT_EQ(nullptr, record_obj);
Ryan Sleevi 2016/07/06 17:48:25 ASSERT_FALSE(record_obj)
+}
} // namespace net
« no previous file with comments | « net/dns/record_rdata.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698