X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FReplaceableTest.cpp;h=af3c4bdcda4c3d861ce0a1acfd49897bead23d2a;hb=HEAD;hp=00eb01d9867ba38fa45de2d3bfeaf90ba853436d;hpb=fbfd3029afb38ba11ff8f403aac3704c47141119;p=folly.git diff --git a/folly/test/ReplaceableTest.cpp b/folly/test/ReplaceableTest.cpp index 00eb01d9..af3c4bdc 100644 --- a/folly/test/ReplaceableTest.cpp +++ b/folly/test/ReplaceableTest.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -22,6 +22,7 @@ using namespace ::testing; using namespace ::folly; namespace { +struct Basic {}; struct alignas(128) BigAlign {}; struct HasConst final { bool const b1; @@ -69,7 +70,7 @@ struct OddA { struct Indestructible { ~Indestructible() = delete; }; -} // anonymous namespace +} // namespace template struct ReplaceableStaticAttributeTest : Test {}; @@ -81,6 +82,7 @@ using StaticAttributeTypes = ::testing::Types< float, double, char[11], + Basic, BigAlign, HasConst, HasRef, @@ -168,6 +170,10 @@ TYPED_TEST(ReplaceableStaticAttributeTest, nothrow_copy_assignable) { std::is_nothrow_copy_constructible::value, std::is_nothrow_copy_assignable>::value); } +TYPED_TEST(ReplaceableStaticAttributeTest, replaceable) { + EXPECT_FALSE(is_replaceable::value); + EXPECT_TRUE(is_replaceable>::value); +} TYPED_TEST(ReplaceableStaticAttributePairTest, copy_construct) { using T = typename TypeParam::first_type; @@ -250,6 +256,18 @@ TEST(ReplaceableTest, Basics) { EXPECT_TRUE(rHasConstB->b1); } +TEST(ReplaceableTest, Constructors) { + Basic b{}; + // From existing `T` + auto rBasicCopy1 = Replaceable(b); + auto rBasicMove1 = Replaceable(std::move(b)); + // From existing `Replaceable` + auto rBasicCopy2 = Replaceable(rBasicCopy1); + auto rBasicMove2 = Replaceable(std::move(rBasicMove1)); + (void)rBasicCopy2; + (void)rBasicMove2; +} + TEST(ReplaceableTest, DestructsWhenExpected) { int i{0}; {