proxygen
ColdClassTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <folly/lang/ColdClass.h>
18 
20 #include <type_traits>
21 
22 using folly::ColdClass;
23 
24 template <class TestClass>
25 static void validateInheritedClass() {
26  // The only verifiable property of ColdClass is that it must not disrupt the
27  // default constructor/destructor, default copy/move constructors and default
28  // copy/move assignment operators when a class derives from it.
30 #if !defined(__GLIBCXX__) || __GNUC__ >= 5
35 #endif
41 }
42 
43 TEST(ColdClassTest, publicInheritance) {
44  struct TestPublic : ColdClass {};
45  validateInheritedClass<TestPublic>();
46 }
47 
48 TEST(ColdClassTest, protectedInheritance) {
49  // Same again, but protected inheritance. Should make no difference.
50  class TestProtected : protected ColdClass {};
51  validateInheritedClass<TestProtected>();
52 }
53 
54 TEST(ColdClassTest, privateInheritance) {
55  // Same again, but private inheritance. Should make no difference.
56  class TestPrivate : ColdClass {};
57  validateInheritedClass<TestPrivate>();
58 }
TEST(ColdClassTest, publicInheritance)
static const char *const value
Definition: Conv.cpp:50
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
static void validateInheritedClass()