proxygen
ReplaceableTest.cpp File Reference

Go to the source code of this file.

Classes

struct  ReplaceableStaticAttributeTest< T >
 
struct  ReplaceableStaticAttributePairTest< T >
 

Typedefs

using StaticAttributeTypes = ::testing::Types< char, short, int, long, float, double, char[11], Basic, BigAlign, HasConst, HasRef, OddA, OddB, Indestructible >
 
using StaticAttributePairTypes = ::testing::Types< std::pair< int, long >, std::pair< OddA, OddB >, std::pair< OddB, OddA >>
 

Functions

 TYPED_TEST_CASE (ReplaceableStaticAttributeTest, StaticAttributeTypes)
 
 TYPED_TEST_CASE (ReplaceableStaticAttributePairTest, StaticAttributePairTypes)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, size)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, align)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, destructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, trivially_destructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, default_constructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, move_constructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, copy_constructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, move_assignable)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, copy_assignable)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, nothrow_destructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, nothrow_default_constructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, nothrow_move_constructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, nothrow_copy_constructible)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, nothrow_move_assignable)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, nothrow_copy_assignable)
 
 TYPED_TEST (ReplaceableStaticAttributeTest, replaceable)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, copy_construct)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, move_construct)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, copy_assign)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, move_assign)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, nothrow_copy_construct)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, nothrow_move_construct)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, nothrow_copy_assign)
 
 TYPED_TEST (ReplaceableStaticAttributePairTest, nothrow_move_assign)
 
 TEST (ReplaceableTest, Basics)
 
 TEST (ReplaceableTest, Constructors)
 
 TEST (ReplaceableTest, DestructsWhenExpected)
 
 TEST (ReplaceableTest, Conversions)
 

Typedef Documentation

using StaticAttributePairTypes = ::testing:: Types<std::pair<int, long>, std::pair<OddA, OddB>, std::pair<OddB, OddA>>

Definition at line 97 of file ReplaceableTest.cpp.

using StaticAttributeTypes = ::testing::Types< char, short, int, long, float, double, char[11], Basic, BigAlign, HasConst, HasRef, OddA, OddB, Indestructible>

Definition at line 91 of file ReplaceableTest.cpp.

Function Documentation

TEST ( ReplaceableTest  ,
Basics   
)

Definition at line 243 of file ReplaceableTest.cpp.

References EXPECT_FALSE, EXPECT_TRUE, and folly::gen::move.

243  {
244  auto rHasConstA = make_replaceable<HasConst>();
245  auto rHasConstB = make_replaceable<HasConst>(false);
246  EXPECT_TRUE(rHasConstA->b1);
247  EXPECT_FALSE(rHasConstB->b1);
248  rHasConstA = rHasConstB;
249  EXPECT_FALSE(rHasConstA->b1);
250  EXPECT_FALSE(rHasConstB->b1);
251  rHasConstB.emplace(true);
252  EXPECT_FALSE(rHasConstA->b1);
253  EXPECT_TRUE(rHasConstB->b1);
254  rHasConstA = std::move(rHasConstB);
255  EXPECT_TRUE(rHasConstA->b1);
256  EXPECT_TRUE(rHasConstB->b1);
257 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ReplaceableTest  ,
Constructors   
)

Definition at line 259 of file ReplaceableTest.cpp.

References b, and folly::gen::move.

259  {
260  Basic b{};
261  // From existing `T`
262  auto rBasicCopy1 = Replaceable<Basic>(b);
263  auto rBasicMove1 = Replaceable<Basic>(std::move(b));
264  // From existing `Replaceable<T>`
265  auto rBasicCopy2 = Replaceable<Basic>(rBasicCopy1);
266  auto rBasicMove2 = Replaceable<Basic>(std::move(rBasicMove1));
267  (void)rBasicCopy2;
268  (void)rBasicMove2;
269 }
char b
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
TEST ( ReplaceableTest  ,
DestructsWhenExpected   
)

Definition at line 271 of file ReplaceableTest.cpp.

References EXPECT_EQ, i, and folly::gen::move.

271  {
272  int i{0};
273  {
274  Replaceable<HasRef> rHasRefA{i};
275  Replaceable<HasRef> rHasRefB{i};
276  EXPECT_EQ(0, i);
277  rHasRefA = rHasRefB;
278  EXPECT_EQ(1, i);
279  rHasRefB.emplace(i);
280  EXPECT_EQ(2, i);
281  rHasRefA = std::move(rHasRefB);
282  EXPECT_EQ(3, i);
283  }
284  EXPECT_EQ(5, i);
285 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
TEST ( ReplaceableTest  ,
Conversions   
)

Definition at line 287 of file ReplaceableTest.cpp.

References folly::in_place(), and folly::gen::move.

287  {
288  Replaceable<OddB> rOddB{in_place, {1, 2, 3}, 4};
289  Replaceable<OddA> rOddA{std::move(rOddB)};
290  Replaceable<OddB> rOddB2{rOddA};
291 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
in_place_tag in_place(in_place_tag={})
Definition: Utility.h:235
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
size   
)

Definition at line 100 of file ReplaceableTest.cpp.

References EXPECT_EQ.

100  {
101  EXPECT_EQ(sizeof(TypeParam), sizeof(Replaceable<TypeParam>));
102 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
align   
)

Definition at line 103 of file ReplaceableTest.cpp.

References EXPECT_EQ.

103  {
104  EXPECT_EQ(alignof(TypeParam), alignof(Replaceable<TypeParam>));
105 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
destructible   
)

Definition at line 106 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

106  {
107  EXPECT_EQ(
109  std::is_destructible<Replaceable<TypeParam>>::value);
110 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
trivially_destructible   
)

Definition at line 111 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

111  {
112  EXPECT_EQ(
114  std::is_trivially_destructible<Replaceable<TypeParam>>::value);
115 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
default_constructible   
)

Definition at line 116 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

116  {
117  EXPECT_EQ(
119  std::is_default_constructible<Replaceable<TypeParam>>::value);
120 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
move_constructible   
)

Definition at line 121 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

121  {
122  EXPECT_EQ(
124  std::is_move_constructible<Replaceable<TypeParam>>::value);
125 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
copy_constructible   
)

Definition at line 126 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

126  {
127  EXPECT_EQ(
129  std::is_copy_constructible<Replaceable<TypeParam>>::value);
130 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
move_assignable   
)

Definition at line 131 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

131  {
132  EXPECT_EQ(
134  std::is_move_assignable<Replaceable<TypeParam>>::value);
135 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
copy_assignable   
)

Definition at line 136 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

136  {
137  EXPECT_EQ(
139  std::is_copy_assignable<Replaceable<TypeParam>>::value);
140 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
nothrow_destructible   
)

Definition at line 141 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

141  {
142  EXPECT_EQ(
144  std::is_nothrow_destructible<Replaceable<TypeParam>>::value);
145 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
nothrow_default_constructible   
)

Definition at line 146 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

146  {
147  EXPECT_EQ(
149  std::is_nothrow_default_constructible<Replaceable<TypeParam>>::value);
150 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
nothrow_move_constructible   
)

Definition at line 151 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

151  {
152  EXPECT_EQ(
154  std::is_nothrow_move_constructible<Replaceable<TypeParam>>::value);
155 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
nothrow_copy_constructible   
)

Definition at line 156 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

156  {
157  EXPECT_EQ(
159  std::is_nothrow_copy_constructible<Replaceable<TypeParam>>::value);
160 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
nothrow_move_assignable   
)

Definition at line 161 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

161  {
162  EXPECT_EQ(
165  std::is_nothrow_move_assignable<Replaceable<TypeParam>>::value);
166 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
nothrow_copy_assignable   
)

Definition at line 167 of file ReplaceableTest.cpp.

References EXPECT_EQ, and value.

167  {
168  EXPECT_EQ(
171  std::is_nothrow_copy_assignable<Replaceable<TypeParam>>::value);
172 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributeTest  ,
replaceable   
)

Definition at line 173 of file ReplaceableTest.cpp.

References EXPECT_FALSE, EXPECT_TRUE, and value.

173  {
175  EXPECT_TRUE(is_replaceable<Replaceable<TypeParam>>::value);
176 }
static const char *const value
Definition: Conv.cpp:50
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
copy_construct   
)

Definition at line 178 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

178  {
179  using T = typename TypeParam::first_type;
180  using U = typename TypeParam::second_type;
181  EXPECT_EQ(
183  (std::is_constructible<Replaceable<T>, Replaceable<U> const&>::value));
184 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
move_construct   
)

Definition at line 185 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

185  {
186  using T = typename TypeParam::first_type;
187  using U = typename TypeParam::second_type;
188  EXPECT_EQ(
190  (std::is_constructible<Replaceable<T>, Replaceable<U>&&>::value));
191 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
copy_assign   
)

Definition at line 192 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

192  {
193  using T = typename TypeParam::first_type;
194  using U = typename TypeParam::second_type;
195  EXPECT_EQ(
198  (std::is_assignable<Replaceable<T>, Replaceable<U> const&>::value));
199 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
move_assign   
)

Definition at line 200 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

200  {
201  using T = typename TypeParam::first_type;
202  using U = typename TypeParam::second_type;
203  EXPECT_EQ(
206  (std::is_assignable<Replaceable<T>, Replaceable<U>&&>::value));
207 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
nothrow_copy_construct   
)

Definition at line 208 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

208  {
209  using T = typename TypeParam::first_type;
210  using U = typename TypeParam::second_type;
211  EXPECT_EQ(
214  (std::is_nothrow_constructible<Replaceable<T>, Replaceable<U> const&>::
215  value));
216 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
nothrow_move_construct   
)

Definition at line 217 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

217  {
218  using T = typename TypeParam::first_type;
219  using U = typename TypeParam::second_type;
220  EXPECT_EQ(
223  (std::is_nothrow_constructible<Replaceable<T>, Replaceable<U>&&>::value));
224 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
nothrow_copy_assign   
)

Definition at line 225 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

225  {
226  using T = typename TypeParam::first_type;
227  using U = typename TypeParam::second_type;
228  EXPECT_EQ(
231  (std::is_nothrow_assignable<Replaceable<T>, Replaceable<U> const&>::
232  value));
233 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50
TYPED_TEST ( ReplaceableStaticAttributePairTest  ,
nothrow_move_assign   
)

Definition at line 234 of file ReplaceableTest.cpp.

References EXPECT_EQ, T, and value.

234  {
235  using T = typename TypeParam::first_type;
236  using U = typename TypeParam::second_type;
237  EXPECT_EQ(
240  (std::is_nothrow_assignable<Replaceable<T>, Replaceable<U>&&>::value));
241 }
#define T(v)
Definition: http_parser.c:233
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const char *const value
Definition: Conv.cpp:50