Commit f70249c0 authored by Ben Hamilton's avatar Ben Hamilton Committed by Facebook Github Bot 8

Fix test/FunctionTest.cpp build breaks

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
parent ca729c2e
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment