From df719d49643e37c2bc07d288bd0e77f10dbb8f8e Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Thu, 18 Jun 2015 15:58:00 -0700 Subject: [PATCH] Make autovector_test runnable in ROCKSDB_LITE Summary: Make autovector_test runnable in ROCKSDB_LITE Test Plan: autovector_test Reviewers: sdong, rven, anthony, kradhakrishnan, IslamAbdelRahman, igor Reviewed By: igor Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D40245 --- util/autovector_test.cc | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/util/autovector_test.cc b/util/autovector_test.cc index c597e36f5..94e992660 100644 --- a/util/autovector_test.cc +++ b/util/autovector_test.cc @@ -18,8 +18,17 @@ namespace rocksdb { using namespace std; class AutoVectorTest : public testing::Test {}; - const unsigned long kSize = 8; + +namespace { +template +void AssertAutoVectorOnlyInStack(autovector* vec, bool result) { +#ifndef ROCKSDB_LITE + ASSERT_EQ(vec->only_in_stack(), result); +#endif // !ROCKSDB_LITE +} +} // namespace + TEST_F(AutoVectorTest, PushBackAndPopBack) { autovector vec; ASSERT_TRUE(vec.empty()); @@ -29,9 +38,9 @@ TEST_F(AutoVectorTest, PushBackAndPopBack) { vec.push_back(i); ASSERT_TRUE(!vec.empty()); if (i < kSize) { - ASSERT_TRUE(vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, true); } else { - ASSERT_TRUE(!vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, false); } ASSERT_EQ(i + 1, vec.size()); ASSERT_EQ(i, vec[i]); @@ -42,7 +51,7 @@ TEST_F(AutoVectorTest, PushBackAndPopBack) { while (size != 0) { vec.pop_back(); // will always be in heap - ASSERT_TRUE(!vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, false); ASSERT_EQ(--size, vec.size()); } @@ -57,9 +66,9 @@ TEST_F(AutoVectorTest, EmplaceBack) { vec.emplace_back(i, ToString(i + 123)); ASSERT_TRUE(!vec.empty()); if (i < kSize) { - ASSERT_TRUE(vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, true); } else { - ASSERT_TRUE(!vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, false); } ASSERT_EQ(i + 1, vec.size()); @@ -69,20 +78,20 @@ TEST_F(AutoVectorTest, EmplaceBack) { vec.clear(); ASSERT_TRUE(vec.empty()); - ASSERT_TRUE(!vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, false); } TEST_F(AutoVectorTest, Resize) { autovector vec; vec.resize(kSize); - ASSERT_TRUE(vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, true); for (size_t i = 0; i < kSize; ++i) { vec[i] = i; } vec.resize(kSize * 2); - ASSERT_TRUE(!vec.only_in_stack()); + AssertAutoVectorOnlyInStack(&vec, false); for (size_t i = 0; i < kSize; ++i) { ASSERT_EQ(vec[i], i); } @@ -99,7 +108,9 @@ void AssertEqual( const autovector& a, const autovector& b) { ASSERT_EQ(a.size(), b.size()); ASSERT_EQ(a.empty(), b.empty()); +#ifndef ROCKSDB_LITE ASSERT_EQ(a.only_in_stack(), b.only_in_stack()); +#endif // !ROCKSDB_LITE for (size_t i = 0; i < a.size(); ++i) { ASSERT_EQ(a[i], b[i]); }