Fix test/FunctionTest.cpp build breaks
authorBen Hamilton <beng@fb.com>
Sat, 28 May 2016 00:00:50 +0000 (17:00 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Sat, 28 May 2016 00:08:32 +0000 (17:08 -0700)
Summary:
The Folly `make check` build is broken with Clang on OS X.

This diff fixes two breaks in `test/FunctionTest.cpp`:

1. `FunctionTest.cpp:39:20: error: implicit instantiation of undefined template 'std::__1::array<int, 100>'`
2. `FunctionTest.cpp:103:3: error: no matching conversion for functional-style cast from 'Function<int (int)>' to '::testing::AssertionResult'`

The first was a missing `#include <array>`, and the second is a workaround for this gtest bug:
https://github.com/google/googletest/issues/429

Reviewed By: djwatson

Differential Revision: D3361188

fbshipit-source-id: 8140de978a2cbaf0f4aab45781ce0d656f03202b

folly/test/FunctionTest.cpp

index 3f1385160f3b1118eee2b35916dcaa9226d58d02..1c18e481d6a9c3e0f9ba11544e0fb663ad04ab6b 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <array>
 #include <cstdarg>
 
 #include <folly/Function.h>
@@ -100,13 +101,15 @@ TEST(Function, Emptiness_T) {
   Function<int(int)> g([](int x) { return x + 1; });
   EXPECT_NE(g, nullptr);
   EXPECT_NE(nullptr, g);
-  EXPECT_TRUE(g);
+  // Explicitly convert to bool to work around
+  // https://github.com/google/googletest/issues/429
+  EXPECT_TRUE(bool(g));
   EXPECT_EQ(100, g(99));
 
   Function<int(int)> h(&func_int_int_add_25);
   EXPECT_NE(h, nullptr);
   EXPECT_NE(nullptr, h);
-  EXPECT_TRUE(h);
+  EXPECT_TRUE(bool(h));
   EXPECT_EQ(125, h(100));
 
   h = {};
@@ -851,7 +854,7 @@ TEST(Function, SelfMoveAssign) {
   Function<int()> f = [] { return 0; };
   Function<int()>& g = f;
   f = std::move(g);
-  EXPECT_TRUE(f);
+  EXPECT_TRUE(bool(f));
 }
 
 TEST(Function, DeducableArguments) {