Commit fce4eabe authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

update tests to build with gcc-4.9

Summary:
Various folly tests failed to compile when using the older gcc-4.9 version.
Since we apparently want to keep supporting gcc-4.9 for a bit longer, update
the code so that it can be compiled with gcc-4.9.

Reviewed By: yfeldblum

Differential Revision: D6817546

fbshipit-source-id: a5224560330b49e94e10d21f81a83538ec7f34e9
parent bbab1089
...@@ -30,9 +30,12 @@ TEST_F(ConstexprTest, constexpr_strlen_cstr) { ...@@ -30,9 +30,12 @@ TEST_F(ConstexprTest, constexpr_strlen_cstr) {
EXPECT_TRUE((std::is_same<const size_t, decltype(a)>::value)); EXPECT_TRUE((std::is_same<const size_t, decltype(a)>::value));
} }
// gcc-4.9 cannot compile the following constexpr code correctly
#if !(defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5)
TEST_F(ConstexprTest, constexpr_strlen_ints) { TEST_F(ConstexprTest, constexpr_strlen_ints) {
constexpr int v[] = {5, 3, 4, 0, 7}; constexpr int v[] = {5, 3, 4, 0, 7};
constexpr auto a = folly::constexpr_strlen(v); constexpr auto a = folly::constexpr_strlen(v);
EXPECT_EQ(3, a); EXPECT_EQ(3, a);
EXPECT_TRUE((std::is_same<const size_t, decltype(a)>::value)); EXPECT_TRUE((std::is_same<const size_t, decltype(a)>::value));
} }
#endif
...@@ -127,7 +127,7 @@ TEST(CachelinePadded, PtrOperator) { ...@@ -127,7 +127,7 @@ TEST(CachelinePadded, PtrOperator) {
CachelinePadded<int> padded; CachelinePadded<int> padded;
EXPECT_TRUE(padded.get() == padded.operator->()); EXPECT_TRUE(padded.get() == padded.operator->());
EXPECT_TRUE(&*padded == padded.get()); EXPECT_TRUE(&*padded == padded.get());
const CachelinePadded<int> constPadded; const auto constPadded = CachelinePadded<int>{};
EXPECT_TRUE(constPadded.get() == constPadded.operator->()); EXPECT_TRUE(constPadded.get() == constPadded.operator->());
EXPECT_TRUE(constPadded.get() == &*constPadded.get()); EXPECT_TRUE(constPadded.get() == &*constPadded.get());
} }
...@@ -148,7 +148,7 @@ TEST(CachelinePadded, PropagatesConstness) { ...@@ -148,7 +148,7 @@ TEST(CachelinePadded, PropagatesConstness) {
padded->assign(&i); padded->assign(&i);
EXPECT_EQ(31415, i); EXPECT_EQ(31415, i);
const CachelinePadded<OverloadedOnConst> constPadded; const auto constPadded = CachelinePadded<OverloadedOnConst>{};
constPadded->assign(&i); constPadded->assign(&i);
EXPECT_EQ(271828, i); EXPECT_EQ(271828, i);
} }
......
...@@ -1208,9 +1208,6 @@ TEST(CRangeFunc, Collection) { ...@@ -1208,9 +1208,6 @@ TEST(CRangeFunc, Collection) {
class IntCollection { class IntCollection {
public: public:
constexpr IntCollection(int* d, size_t s) : data_(d), size_(s) {} constexpr IntCollection(int* d, size_t s) : data_(d), size_(s) {}
constexpr int* data() {
return data_;
}
constexpr int const* data() const { constexpr int const* data() const {
return data_; return data_;
} }
......
...@@ -84,7 +84,7 @@ TEST(Try, MoveConstRvalue) { ...@@ -84,7 +84,7 @@ TEST(Try, MoveConstRvalue) {
// and you want to fetch the value from the Try and move it into a member // and you want to fetch the value from the Try and move it into a member
{ {
const Try<MutableContainer> t{in_place}; const Try<MutableContainer> t{in_place};
auto val = MoveConstructOnly{std::move(t).value().val}; auto val = MoveConstructOnly(std::move(t).value().val);
static_cast<void>(val); static_cast<void>(val);
} }
{ {
......
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