summaryrefslogtreecommitdiff
path: root/src/reference_table_test.cc
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-05-09 09:34:45 -0700
committer Elliott Hughes <enh@google.com> 2012-05-09 09:34:45 -0700
commit73e66f73f5093b64f2b023ebbb85916a13d5c937 (patch)
treefca2dcdf446aec9aad2a3096098c038279279e53 /src/reference_table_test.cc
parent145d491d1a30b291eb3ea608507a04451237f327 (diff)
Tidy up and finish reference table dumping.
Change-Id: I9f0d214e27a75d373e3144b738f1e3da51bbc0ca
Diffstat (limited to 'src/reference_table_test.cc')
-rw-r--r--src/reference_table_test.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/reference_table_test.cc b/src/reference_table_test.cc
index 4c1e67fb11..c7c1cc6248 100644
--- a/src/reference_table_test.cc
+++ b/src/reference_table_test.cc
@@ -27,10 +27,10 @@ TEST_F(ReferenceTableTest, Basics) {
Object* o1 = String::AllocFromModifiedUtf8("hello");
Object* o2 = ShortArray::Alloc(0);
- // TODO: rewrite Dump to take a std::ostream& so we can test it better.
-
ReferenceTable rt("test", 0, 4);
- rt.Dump();
+ std::ostringstream oss1;
+ rt.Dump(oss1);
+ EXPECT_TRUE(oss1.str().find("(empty)") != std::string::npos) << oss1.str();
EXPECT_EQ(0U, rt.Size());
rt.Remove(NULL);
EXPECT_EQ(0U, rt.Size());
@@ -40,8 +40,16 @@ TEST_F(ReferenceTableTest, Basics) {
EXPECT_EQ(1U, rt.Size());
rt.Add(o2);
EXPECT_EQ(2U, rt.Size());
- rt.Dump();
+ rt.Add(o2);
+ EXPECT_EQ(3U, rt.Size());
+ std::ostringstream oss2;
+ rt.Dump(oss2);
+ EXPECT_TRUE(oss2.str().find("Last 3 entries (of 3):") != std::string::npos) << oss2.str();
+ EXPECT_TRUE(oss2.str().find("1 of java.lang.String") != std::string::npos) << oss2.str();
+ EXPECT_TRUE(oss2.str().find("2 of short[] (1 unique instances)") != std::string::npos) << oss2.str();
rt.Remove(o1);
+ EXPECT_EQ(2U, rt.Size());
+ rt.Remove(o2);
EXPECT_EQ(1U, rt.Size());
rt.Remove(o2);
EXPECT_EQ(0U, rt.Size());