inlined_vector_exception_safety_test.cc
Go to the documentation of this file.
1 // Copyright 2019 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <memory>
16 
17 #include "gtest/gtest.h"
20 
21 namespace {
22 
23 constexpr size_t kInlined = 4;
24 constexpr size_t kSmallSize = kInlined / 2;
25 constexpr size_t kLargeSize = kInlined * 2;
26 
28 using ThrowerAlloc = testing::ThrowingAllocator<Thrower>;
29 
30 template <typename Allocator = std::allocator<Thrower>>
32 
33 TEST(InlinedVector, DefaultConstructor) {
34  testing::TestThrowingCtor<InlVec<>>();
35 
36  testing::TestThrowingCtor<InlVec<ThrowerAlloc>>();
37 }
38 
39 TEST(InlinedVector, AllocConstructor) {
40  auto alloc = std::allocator<Thrower>();
41  testing::TestThrowingCtor<InlVec<>>(alloc);
42 
43  auto throw_alloc = ThrowerAlloc();
44  testing::TestThrowingCtor<InlVec<ThrowerAlloc>>(throw_alloc);
45 }
46 
47 TEST(InlinedVector, Clear) {
48  auto small_vec = InlVec<>(kSmallSize);
49  EXPECT_TRUE(testing::TestNothrowOp([&]() { small_vec.clear(); }));
50 
51  auto large_vec = InlVec<>(kLargeSize);
52  EXPECT_TRUE(testing::TestNothrowOp([&]() { large_vec.clear(); }));
53 }
54 
55 } // namespace
testing::AssertionResult TestNothrowOp(const Operation &operation)
TEST(Symbolize, Unimplemented)
std::allocator< int > alloc


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:19:56