proxygen
HasMemberFnTraitsTest.cpp File Reference
#include <folly/Traits.h>
#include <folly/portability/GTest.h>
#include <glog/logging.h>
#include <string>

Go to the source code of this file.

Classes

class  Foo
 
struct  Bar
 
struct  Gaz
 
struct  NoCV
 
struct  Const
 
struct  Volatile
 
struct  CV
 

Macros

#define LOG_VALUE(x)   log_value(#x, x)
 

Functions

 FOLLY_CREATE_HAS_MEMBER_FN_TRAITS (has_test, test)
 
bool log_value (const char *what, bool result)
 
 TEST (HasMemberFnTraits, DirectMembers)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

#define LOG_VALUE (   x)    log_value(#x, x)

Definition at line 74 of file HasMemberFnTraitsTest.cpp.

Referenced by TEST().

Function Documentation

FOLLY_CREATE_HAS_MEMBER_FN_TRAITS ( has_test  ,
test   
)
bool log_value ( const char *  what,
bool  result 
)

Definition at line 69 of file HasMemberFnTraitsTest.cpp.

References folly::INFO.

69  {
70  LOG(INFO) << what << ": " << boolalpha << result;
71  return result;
72 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 135 of file HasMemberFnTraitsTest.cpp.

References testing::InitGoogleTest(), and RUN_ALL_TESTS().

135  {
137  return RUN_ALL_TESTS();
138 }
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: gtest.h:2232
char ** argv
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: gtest.cc:5370
TEST ( HasMemberFnTraits  ,
DirectMembers   
)

Definition at line 76 of file HasMemberFnTraitsTest.cpp.

References folly::gen::Const, EXPECT_FALSE, EXPECT_TRUE, LOG_VALUE, and value.

76  {
77  EXPECT_TRUE(LOG_VALUE((has_test<Foo, int()>::value)));
78  EXPECT_TRUE(LOG_VALUE((has_test<Foo, int() const>::value)));
79  EXPECT_FALSE(LOG_VALUE((has_test<Foo, double(int, long)>::value)));
80  EXPECT_TRUE(LOG_VALUE((has_test<Foo, string(const string&) const>::value)));
81  EXPECT_FALSE(LOG_VALUE((has_test<Foo, long(int) const>::value)));
82  EXPECT_FALSE(LOG_VALUE((has_test<Foo, string(string) const>::value)));
83 
84  EXPECT_TRUE(LOG_VALUE((has_test<Bar, int()>::value)));
85  EXPECT_FALSE(LOG_VALUE((has_test<Bar, int() const>::value)));
86  EXPECT_TRUE(LOG_VALUE((has_test<Bar, double(int, long)>::value)));
87  EXPECT_FALSE(LOG_VALUE((has_test<Bar, string(const string&) const>::value)));
88  EXPECT_TRUE(LOG_VALUE((has_test<Bar, long(int) const>::value)));
89  EXPECT_FALSE(LOG_VALUE((has_test<Bar, string(string) const>::value)));
90 
91  EXPECT_TRUE(LOG_VALUE((has_test<Gaz, void()>::value)));
92  EXPECT_TRUE(LOG_VALUE((has_test<Gaz, void() const>::value)));
93  EXPECT_TRUE(LOG_VALUE((has_test<Gaz, void() /* nolint */ volatile>::value)));
95  LOG_VALUE((has_test<Gaz, void() const /* nolint */ volatile>::value)));
97  LOG_VALUE((has_test<Gaz, void() /* nolint */ volatile const>::value)));
98 
99  EXPECT_TRUE(LOG_VALUE((has_test<NoCV, void()>::value)));
100  EXPECT_FALSE(LOG_VALUE((has_test<NoCV, void() const>::value)));
101  EXPECT_FALSE(
102  LOG_VALUE((has_test<NoCV, void() /* nolint */ volatile>::value)));
103  EXPECT_FALSE(
104  LOG_VALUE((has_test<NoCV, void() const /* nolint */ volatile>::value)));
105  EXPECT_FALSE(
106  LOG_VALUE((has_test<NoCV, void() /* nolint */ volatile const>::value)));
107 
108  EXPECT_FALSE(LOG_VALUE((has_test<Const, void()>::value)));
109  EXPECT_TRUE(LOG_VALUE((has_test<Const, void() const>::value)));
110  EXPECT_FALSE(
111  LOG_VALUE((has_test<Const, void() /* nolint */ volatile>::value)));
112  EXPECT_FALSE(
113  LOG_VALUE((has_test<Const, void() const /* nolint */ volatile>::value)));
114  EXPECT_FALSE(
115  LOG_VALUE((has_test<Const, void() /* nolint */ volatile const>::value)));
116 
117  EXPECT_FALSE(LOG_VALUE((has_test<Volatile, void()>::value)));
118  EXPECT_FALSE(LOG_VALUE((has_test<Volatile, void() const>::value)));
119  EXPECT_TRUE(
120  LOG_VALUE((has_test<Volatile, void() /* nolint */ volatile>::value)));
122  (has_test<Volatile, void() const /* nolint */ volatile>::value)));
124  (has_test<Volatile, void() /* nolint */ volatile const>::value)));
125 
126  EXPECT_FALSE(LOG_VALUE((has_test<CV, void()>::value)));
127  EXPECT_FALSE(LOG_VALUE((has_test<CV, void() const>::value)));
128  EXPECT_FALSE(LOG_VALUE((has_test<CV, void() /* nolint */ volatile>::value)));
129  EXPECT_TRUE(
130  LOG_VALUE((has_test<CV, void() const /* nolint */ volatile>::value)));
131  EXPECT_TRUE(
132  LOG_VALUE((has_test<CV, void() /* nolint */ volatile const>::value)));
133 }
#define LOG_VALUE(x)
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