Index: net/dns/record_rdata_unittest.cc |
diff --git a/net/dns/record_rdata_unittest.cc b/net/dns/record_rdata_unittest.cc |
index 30ce8be302b72226e2b473a8674fdcd52acf035e..90bac446e2eb1fe9c51d2951115bbea50bbe3205 100644 |
--- a/net/dns/record_rdata_unittest.cc |
+++ b/net/dns/record_rdata_unittest.cc |
@@ -10,6 +10,11 @@ |
namespace net { |
+base::StringPiece MakeStringPiece(const uint8* data, unsigned size) { |
+ const char* data_cc = reinterpret_cast<const char*>(data); |
+ return base::StringPiece(data_cc, size); |
+} |
+ |
TEST(RecordRdataTest, ParseSrvRecord) { |
scoped_ptr<SrvRecordRdata> record1_obj; |
scoped_ptr<SrvRecordRdata> record2_obj; |
@@ -17,25 +22,26 @@ TEST(RecordRdataTest, ParseSrvRecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x00', '\x01', |
- '\x00', '\x02', |
- '\x00', '\x50', |
- '\x03', 'w', 'w', 'w', |
- '\x06', 'g', 'o', 'o', 'g', 'l', 'e', |
- '\x03', 'c', 'o', 'm', |
- '\x00', |
- '\x01', '\x01', |
- '\x01', '\x02', |
- '\x01', '\x03', |
- '\x04', 'w', 'w', 'w', '2', |
- '\xc0', '\x0a', // Pointer to "google.com" |
+ const uint8 record[] = { |
+ 0x00, 0x01, |
+ 0x00, 0x02, |
+ 0x00, 0x50, |
+ 0x03, 'w', 'w', 'w', |
+ 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
+ 0x03, 'c', 'o', 'm', |
+ 0x00, |
+ 0x01, 0x01, |
+ 0x01, 0x02, |
+ 0x01, 0x03, |
+ 0x04, 'w', 'w', 'w', '2', |
+ 0xc0, 0x0a, // Pointer to "google.com" |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
const unsigned first_record_len = 22; |
- base::StringPiece record1_strpiece(record, first_record_len); |
- base::StringPiece record2_strpiece( |
+ base::StringPiece record1_strpiece = MakeStringPiece( |
+ record, first_record_len); |
+ base::StringPiece record2_strpiece = MakeStringPiece( |
record + first_record_len, sizeof(record) - first_record_len); |
record1_obj = SrvRecordRdata::Create(record1_strpiece, parser); |
@@ -64,12 +70,12 @@ TEST(RecordRdataTest, ParseARecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x7F', '\x00', '\x00', '\x01' // 127.0.0.1 |
+ const uint8 record[] = { |
+ 0x7F, 0x00, 0x00, 0x01 // 127.0.0.1 |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
- base::StringPiece record_strpiece(record, sizeof(record)); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
record_obj = ARecordRdata::Create(record_strpiece, parser); |
ASSERT_TRUE(record_obj != NULL); |
@@ -85,15 +91,15 @@ TEST(RecordRdataTest, ParseAAAARecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x12', '\x34', '\x56', '\x78', |
- '\x00', '\x00', '\x00', '\x00', |
- '\x00', '\x00', '\x00', '\x00', |
- '\x00', '\x00', '\x00', '\x09' // 1234:5678::9A |
+ const uint8 record[] = { |
+ 0x12, 0x34, 0x56, 0x78, |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x09 // 1234:5678::9A |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
- base::StringPiece record_strpiece(record, sizeof(record)); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
record_obj = AAAARecordRdata::Create(record_strpiece, parser); |
ASSERT_TRUE(record_obj != NULL); |
@@ -110,15 +116,15 @@ TEST(RecordRdataTest, ParseCnameRecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x03', 'w', 'w', 'w', |
- '\x06', 'g', 'o', 'o', 'g', 'l', 'e', |
- '\x03', 'c', 'o', 'm', |
- '\x00' |
+ const uint8 record[] = { |
+ 0x03, 'w', 'w', 'w', |
+ 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
+ 0x03, 'c', 'o', 'm', |
+ 0x00 |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
- base::StringPiece record_strpiece(record, sizeof(record)); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
record_obj = CnameRecordRdata::Create(record_strpiece, parser); |
ASSERT_TRUE(record_obj != NULL); |
@@ -134,15 +140,15 @@ TEST(RecordRdataTest, ParsePtrRecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x03', 'w', 'w', 'w', |
- '\x06', 'g', 'o', 'o', 'g', 'l', 'e', |
- '\x03', 'c', 'o', 'm', |
- '\x00' |
+ const uint8 record[] = { |
+ 0x03, 'w', 'w', 'w', |
+ 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
+ 0x03, 'c', 'o', 'm', |
+ 0x00 |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
- base::StringPiece record_strpiece(record, sizeof(record)); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
record_obj = PtrRecordRdata::Create(record_strpiece, parser); |
ASSERT_TRUE(record_obj != NULL); |
@@ -158,14 +164,14 @@ TEST(RecordRdataTest, ParseTxtRecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x03', 'w', 'w', 'w', |
- '\x06', 'g', 'o', 'o', 'g', 'l', 'e', |
- '\x03', 'c', 'o', 'm' |
+ const uint8 record[] = { |
+ 0x03, 'w', 'w', 'w', |
+ 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
+ 0x03, 'c', 'o', 'm' |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
- base::StringPiece record_strpiece(record, sizeof(record)); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
record_obj = TxtRecordRdata::Create(record_strpiece, parser); |
ASSERT_TRUE(record_obj != NULL); |
@@ -186,16 +192,16 @@ TEST(RecordRdataTest, ParseNsecRecord) { |
// These are just the rdata portions of the DNS records, rather than complete |
// records, but it works well enough for this test. |
- const char record[] = { |
- '\x03', 'w', 'w', 'w', |
- '\x06', 'g', 'o', 'o', 'g', 'l', 'e', |
- '\x03', 'c', 'o', 'm', |
- '\x00', |
- '\x00', '\x02', '\x40', '\x01' |
+ const uint8 record[] = { |
+ 0x03, 'w', 'w', 'w', |
+ 0x06, 'g', 'o', 'o', 'g', 'l', 'e', |
+ 0x03, 'c', 'o', 'm', |
+ 0x00, |
+ 0x00, 0x02, 0x40, 0x01 |
}; |
DnsRecordParser parser(record, sizeof(record), 0); |
- base::StringPiece record_strpiece(record, sizeof(record)); |
+ base::StringPiece record_strpiece = MakeStringPiece(record, sizeof(record)); |
record_obj = NsecRecordRdata::Create(record_strpiece, parser); |
ASSERT_TRUE(record_obj != NULL); |