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

Unified Diff: net/quic/quic_data_writer_test.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/quic/quic_data_writer.cc ('k') | net/quic/quic_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_data_writer_test.cc
diff --git a/net/quic/quic_data_writer_test.cc b/net/quic/quic_data_writer_test.cc
index 07346c78891a2c598e9a52441d2d181166e77b83..01b3c6d060b40fdf9f77cb587b65e5ebb365f876 100644
--- a/net/quic/quic_data_writer_test.cc
+++ b/net/quic/quic_data_writer_test.cc
@@ -14,7 +14,8 @@ namespace test {
namespace {
TEST(QuicDataWriterTest, WriteUInt8ToOffset) {
- QuicDataWriter writer(4);
+ char buffer[4];
+ QuicDataWriter writer(4, buffer);
writer.WriteUInt32(0xfefdfcfb);
EXPECT_TRUE(writer.WriteUInt8ToOffset(1, 0));
@@ -22,16 +23,15 @@ TEST(QuicDataWriterTest, WriteUInt8ToOffset) {
EXPECT_TRUE(writer.WriteUInt8ToOffset(3, 2));
EXPECT_TRUE(writer.WriteUInt8ToOffset(4, 3));
- scoped_ptr<char[]> data(writer.take());
-
- EXPECT_EQ(1, data[0]);
- EXPECT_EQ(2, data[1]);
- EXPECT_EQ(3, data[2]);
- EXPECT_EQ(4, data[3]);
+ EXPECT_EQ(1, writer.data()[0]);
+ EXPECT_EQ(2, writer.data()[1]);
+ EXPECT_EQ(3, writer.data()[2]);
+ EXPECT_EQ(4, writer.data()[3]);
}
TEST(QuicDataWriterDeathTest, WriteUInt8ToOffset) {
- QuicDataWriter writer(4);
+ char buffer[4];
+ QuicDataWriter writer(4, buffer);
EXPECT_DFATAL(EXPECT_FALSE(writer.WriteUInt8ToOffset(5, 4)),
"offset: 4 >= capacity: 4");
@@ -80,10 +80,10 @@ TEST(QuicDataWriterTest, WriteUFloat16) {
int num_test_cases = sizeof(test_cases) / sizeof(test_cases[0]);
for (int i = 0; i < num_test_cases; ++i) {
- QuicDataWriter writer(2);
+ char buffer[2];
+ QuicDataWriter writer(2, buffer);
EXPECT_TRUE(writer.WriteUFloat16(test_cases[i].decoded));
- scoped_ptr<char[]> data(writer.take());
- EXPECT_EQ(test_cases[i].encoded, *reinterpret_cast<uint16*>(data.get()));
+ EXPECT_EQ(test_cases[i].encoded, *reinterpret_cast<uint16*>(writer.data()));
}
}
@@ -144,17 +144,18 @@ TEST(QuicDataWriterTest, RoundTripUFloat16) {
// Check we're always within the promised range.
EXPECT_LT(value, GG_UINT64_C(0x3FFC0000000));
previous_value = value;
- QuicDataWriter writer(6);
+ char buffer[6];
+ QuicDataWriter writer(6, buffer);
EXPECT_TRUE(writer.WriteUFloat16(value - 1));
EXPECT_TRUE(writer.WriteUFloat16(value));
EXPECT_TRUE(writer.WriteUFloat16(value + 1));
- scoped_ptr<char[]> data(writer.take());
// Check minimal decoding (previous decoding has previous encoding).
- EXPECT_EQ(i-1, *reinterpret_cast<uint16*>(data.get()));
+ EXPECT_EQ(i - 1, *reinterpret_cast<uint16*>(writer.data()));
// Check roundtrip.
- EXPECT_EQ(i, *reinterpret_cast<uint16*>(data.get() + 2));
+ EXPECT_EQ(i, *reinterpret_cast<uint16*>(writer.data() + 2));
// Check next decoding.
- EXPECT_EQ(i < 4096? i+1 : i, *reinterpret_cast<uint16*>(data.get() + 4));
+ EXPECT_EQ(i < 4096 ? i + 1 : i,
+ *reinterpret_cast<uint16*>(writer.data() + 4));
}
}
« no previous file with comments | « net/quic/quic_data_writer.cc ('k') | net/quic/quic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698