/*
- * Copyright 2004-present Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using namespace ::folly;
namespace {
+struct Basic {};
struct alignas(128) BigAlign {};
struct HasConst final {
bool const b1;
struct Indestructible {
~Indestructible() = delete;
};
-} // anonymous namespace
+} // namespace
template <typename T>
struct ReplaceableStaticAttributeTest : Test {};
float,
double,
char[11],
+ Basic,
BigAlign,
HasConst,
HasRef,
std::is_nothrow_copy_constructible<TypeParam>::value,
std::is_nothrow_copy_assignable<Replaceable<TypeParam>>::value);
}
+TYPED_TEST(ReplaceableStaticAttributeTest, replaceable) {
+ EXPECT_FALSE(is_replaceable<TypeParam>::value);
+ EXPECT_TRUE(is_replaceable<Replaceable<TypeParam>>::value);
+}
TYPED_TEST(ReplaceableStaticAttributePairTest, copy_construct) {
using T = typename TypeParam::first_type;
EXPECT_TRUE(rHasConstB->b1);
}
+TEST(ReplaceableTest, Constructors) {
+ Basic b{};
+ // From existing `T`
+ auto rBasicCopy1 = Replaceable<Basic>(b);
+ auto rBasicMove1 = Replaceable<Basic>(std::move(b));
+ // From existing `Replaceable<T>`
+ auto rBasicCopy2 = Replaceable<Basic>(rBasicCopy1);
+ auto rBasicMove2 = Replaceable<Basic>(std::move(rBasicMove1));
+ (void)rBasicCopy2;
+ (void)rBasicMove2;
+}
+
TEST(ReplaceableTest, DestructsWhenExpected) {
int i{0};
{