summaryrefslogtreecommitdiffstats
path: root/courgette/streams_unittest.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 20:19:49 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-22 20:19:49 +0000
commitc8240b1c3519b35de243b0fb91af409d59a5808c (patch)
treed7f20f227779c4c32fdd2851037255f1d660673a /courgette/streams_unittest.cc
parentd64abe1c12dbe8dab68adee605fa143dc9020f86 (diff)
downloadchromium_src-c8240b1c3519b35de243b0fb91af409d59a5808c.zip
chromium_src-c8240b1c3519b35de243b0fb91af409d59a5808c.tar.gz
chromium_src-c8240b1c3519b35de243b0fb91af409d59a5808c.tar.bz2
Identifying call sites that need to handle out of memory situations in Courgette.
There's no functional change here, only interface changes: * Change methods that are known to fail out in the field to return bool instead of void. * Where those methods are called, check the return value and report errors * In debug builds use a specialized template class that forces callers to check return values (this is possible at compile time in gcc, but unfortunately not in VS). The next step will be to change the implementation to not use STL containers. TEST=Run courgette tests. BUG=74777 Review URL: http://codereview.chromium.org/6716006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79030 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/streams_unittest.cc')
-rw-r--r--courgette/streams_unittest.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/courgette/streams_unittest.cc b/courgette/streams_unittest.cc
index 64c12dd..d0903c9 100644
--- a/courgette/streams_unittest.cc
+++ b/courgette/streams_unittest.cc
@@ -12,7 +12,7 @@ TEST(StreamsTest, SimpleWriteRead) {
const unsigned int kValue1 = 12345;
courgette::SinkStream sink;
- sink.WriteVarint32(kValue1);
+ EXPECT_TRUE(sink.WriteVarint32(kValue1));
const uint8* sink_buffer = sink.Buffer();
size_t length = sink.Length();
@@ -30,7 +30,7 @@ TEST(StreamsTest, SimpleWriteRead) {
TEST(StreamsTest, SimpleWriteRead2) {
courgette::SinkStream sink;
- sink.Write("Hello", 5);
+ EXPECT_TRUE(sink.Write("Hello", 5));
const uint8* sink_buffer = sink.Buffer();
size_t sink_length = sink.Length();
@@ -51,11 +51,11 @@ TEST(StreamsTest, StreamSetWriteRead) {
const unsigned int kValue1 = 12345;
- out.stream(3)->WriteVarint32(kValue1);
+ EXPECT_TRUE(out.stream(3)->WriteVarint32(kValue1));
courgette::SinkStream collected;
- out.CopyTo(&collected);
+ EXPECT_TRUE(out.CopyTo(&collected));
const uint8* collected_buffer = collected.Buffer();
size_t collected_length = collected.Length();
@@ -90,12 +90,12 @@ TEST(StreamsTest, StreamSetWriteRead2) {
for (size_t i = 0; data[i] != kEnd; i += 2) {
size_t id = data[i];
size_t datum = data[i + 1];
- out.stream(id)->WriteVarint32(datum);
+ EXPECT_TRUE(out.stream(id)->WriteVarint32(datum));
}
courgette::SinkStream collected;
- out.CopyTo(&collected);
+ EXPECT_TRUE(out.CopyTo(&collected));
courgette::SourceStreamSet in;
bool can_init = in.Init(collected.Buffer(), collected.Length());
@@ -129,9 +129,9 @@ TEST(StreamsTest, SignedVarint32) {
for (size_t i = 0; i < sizeof(data)/sizeof(data[0]); ++i) {
int32 basis = data[i];
for (int delta = -4; delta <= 4; ++delta) {
- out.WriteVarint32Signed(basis + delta);
+ EXPECT_TRUE(out.WriteVarint32Signed(basis + delta));
values.push_back(basis + delta);
- out.WriteVarint32Signed(-basis + delta);
+ EXPECT_TRUE(out.WriteVarint32Signed(-basis + delta));
values.push_back(-basis + delta);
}
}
@@ -155,18 +155,18 @@ TEST(StreamsTest, StreamSetReadWrite) {
{ // Local scope for temporary stream sets.
courgette::SinkStreamSet subset1;
- subset1.stream(3)->WriteVarint32(30000);
- subset1.stream(5)->WriteVarint32(50000);
- out.WriteSet(&subset1);
+ EXPECT_TRUE(subset1.stream(3)->WriteVarint32(30000));
+ EXPECT_TRUE(subset1.stream(5)->WriteVarint32(50000));
+ EXPECT_TRUE(out.WriteSet(&subset1));
courgette::SinkStreamSet subset2;
- subset2.stream(2)->WriteVarint32(20000);
- subset2.stream(6)->WriteVarint32(60000);
- out.WriteSet(&subset2);
+ EXPECT_TRUE(subset2.stream(2)->WriteVarint32(20000));
+ EXPECT_TRUE(subset2.stream(6)->WriteVarint32(60000));
+ EXPECT_TRUE(out.WriteSet(&subset2));
}
courgette::SinkStream collected;
- out.CopyTo(&collected);
+ EXPECT_TRUE(out.CopyTo(&collected));
courgette::SourceStreamSet in;
bool can_init_in = in.Init(collected.Buffer(), collected.Length());
EXPECT_TRUE(can_init_in);