Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <memory>
00016
00017 #include "gtest/gtest.h"
00018 #include "absl/base/internal/exception_safety_testing.h"
00019 #include "absl/container/inlined_vector.h"
00020
00021 namespace {
00022
00023 constexpr size_t kInlined = 4;
00024 constexpr size_t kSmallSize = kInlined / 2;
00025 constexpr size_t kLargeSize = kInlined * 2;
00026
00027 using Thrower = testing::ThrowingValue<>;
00028 using ThrowerAlloc = testing::ThrowingAllocator<Thrower>;
00029
00030 template <typename Allocator = std::allocator<Thrower>>
00031 using InlVec = absl::InlinedVector<Thrower, kInlined, Allocator>;
00032
00033 TEST(InlinedVector, DefaultConstructor) {
00034 testing::TestThrowingCtor<InlVec<>>();
00035
00036 testing::TestThrowingCtor<InlVec<ThrowerAlloc>>();
00037 }
00038
00039 TEST(InlinedVector, AllocConstructor) {
00040 auto alloc = std::allocator<Thrower>();
00041 testing::TestThrowingCtor<InlVec<>>(alloc);
00042
00043 auto throw_alloc = ThrowerAlloc();
00044 testing::TestThrowingCtor<InlVec<ThrowerAlloc>>(throw_alloc);
00045 }
00046
00047 TEST(InlinedVector, Clear) {
00048 auto small_vec = InlVec<>(kSmallSize);
00049 EXPECT_TRUE(testing::TestNothrowOp([&]() { small_vec.clear(); }));
00050
00051 auto large_vec = InlVec<>(kLargeSize);
00052 EXPECT_TRUE(testing::TestNothrowOp([&]() { large_vec.clear(); }));
00053 }
00054
00055 }