resize_uninitialized_test.cc
Go to the documentation of this file.
1 // Copyright 2017 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 
16 
17 #include "gtest/gtest.h"
18 
19 namespace {
20 
21 int resize_call_count = 0;
22 
23 struct resizable_string {
24  void resize(size_t) { resize_call_count += 1; }
25 };
26 
27 int resize_default_init_call_count = 0;
28 
29 struct resize_default_init_string {
30  void resize(size_t) { resize_call_count += 1; }
31  void __resize_default_init(size_t) { resize_default_init_call_count += 1; }
32 };
33 
34 TEST(ResizeUninit, WithAndWithout) {
35  resize_call_count = 0;
36  resize_default_init_call_count = 0;
37  {
38  resizable_string rs;
39 
40  EXPECT_EQ(resize_call_count, 0);
41  EXPECT_EQ(resize_default_init_call_count, 0);
42  EXPECT_FALSE(
44  EXPECT_EQ(resize_call_count, 0);
45  EXPECT_EQ(resize_default_init_call_count, 0);
47  EXPECT_EQ(resize_call_count, 1);
48  EXPECT_EQ(resize_default_init_call_count, 0);
49  }
50 
51  resize_call_count = 0;
52  resize_default_init_call_count = 0;
53  {
54  resize_default_init_string rus;
55 
56  EXPECT_EQ(resize_call_count, 0);
57  EXPECT_EQ(resize_default_init_call_count, 0);
58  EXPECT_TRUE(
60  EXPECT_EQ(resize_call_count, 0);
61  EXPECT_EQ(resize_default_init_call_count, 0);
63  EXPECT_EQ(resize_call_count, 0);
64  EXPECT_EQ(resize_default_init_call_count, 1);
65  }
66 }
67 
68 } // namespace
void STLStringResizeUninitialized(string_type *s, size_t new_size)
constexpr bool STLStringSupportsNontrashingResize(string_type *)
TEST(Symbolize, Unimplemented)


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