Commit d5bf7f5a authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook GitHub Bot

Patch unit tests to work with GCC

Summary:
GmockHelpersTest.cpp is the only one that fails to build with GCC after this change.
Also only 5 tests are failing at this point.

Reviewed By: pixelb

Differential Revision: D27728248

fbshipit-source-id: ded994f466347a8826ba90429a13237c21d3af5e
parent b471fe2a
...@@ -499,7 +499,7 @@ TEST(AsyncGenerator, YieldCoError) { ...@@ -499,7 +499,7 @@ TEST(AsyncGenerator, YieldCoError) {
try { try {
(void)co_await gen.next(); (void)co_await gen.next();
CHECK(false); CHECK(false);
} catch (SomeError) { } catch (const SomeError&) {
} }
}()); }());
} }
......
...@@ -806,8 +806,8 @@ TEST_F(CollectAllRangeTest, VectorOfTaskWithExecutorUsage) { ...@@ -806,8 +806,8 @@ TEST_F(CollectAllRangeTest, VectorOfTaskWithExecutorUsage) {
std::vector<folly::coro::TaskWithExecutor<int>> tasks; std::vector<folly::coro::TaskWithExecutor<int>> tasks;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
tasks.push_back( tasks.push_back(
[](int i) -> folly::coro::Task<int> { co_return i + 1; }(i) [](int idx) -> folly::coro::Task<int> { co_return idx + 1; }(i)
.scheduleOn(&threadPool)); .scheduleOn(&threadPool));
} }
auto results = co_await folly::coro::collectAllRange(std::move(tasks)); auto results = co_await folly::coro::collectAllRange(std::move(tasks));
...@@ -1208,9 +1208,9 @@ TEST_F(CollectAllWindowedTest, ConcurrentTasks) { ...@@ -1208,9 +1208,9 @@ TEST_F(CollectAllWindowedTest, ConcurrentTasks) {
auto results = blockingWait(collectAllWindowed( auto results = blockingWait(collectAllWindowed(
[&]() -> Generator<Task<std::string>&&> { [&]() -> Generator<Task<std::string>&&> {
for (int i = 0; i < 10'000; ++i) { for (int i = 0; i < 10'000; ++i) {
co_yield [](int i) -> Task<std::string> { co_yield [](int idx) -> Task<std::string> {
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
co_return folly::to<std::string>(i); co_return folly::to<std::string>(idx);
}(i); }(i);
} }
}(), }(),
...@@ -1345,23 +1345,23 @@ TEST_F(CollectAllWindowedTest, MultipleFailuresPropagatesFirstError) { ...@@ -1345,23 +1345,23 @@ TEST_F(CollectAllWindowedTest, MultipleFailuresPropagatesFirstError) {
folly::coro::blockingWait(folly::coro::collectAllWindowed( folly::coro::blockingWait(folly::coro::collectAllWindowed(
[]() -> folly::coro::Generator<folly::coro::Task<int>&&> { []() -> folly::coro::Generator<folly::coro::Task<int>&&> {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
co_yield [](int i) -> folly::coro::Task<int> { co_yield [](int idx) -> folly::coro::Task<int> {
using namespace std::literals::chrono_literals; using namespace std::literals::chrono_literals;
if (i == 3) { if (idx == 3) {
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorA{}; throw ErrorA{};
} else if (i == 7) { } else if (idx == 7) {
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorB{}; throw ErrorB{};
} }
co_return i; co_return idx;
}(i); }(i);
} }
}(), }(),
5)); 5));
CHECK(false); // Should have thrown. CHECK(false); // Should have thrown.
} catch (ErrorB) { } catch (const ErrorB&) {
// Expected. // Expected.
} }
} }
...@@ -1487,8 +1487,8 @@ TEST_F(CollectAllWindowedTest, VectorOfTaskWithExecutorUsage) { ...@@ -1487,8 +1487,8 @@ TEST_F(CollectAllWindowedTest, VectorOfTaskWithExecutorUsage) {
std::vector<folly::coro::TaskWithExecutor<int>> tasks; std::vector<folly::coro::TaskWithExecutor<int>> tasks;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
tasks.push_back( tasks.push_back(
[](int i) -> folly::coro::Task<int> { co_return i + 1; }(i) [](int idx) -> folly::coro::Task<int> { co_return idx + 1; }(i)
.scheduleOn(&threadPool)); .scheduleOn(&threadPool));
} }
auto results = auto results =
...@@ -1507,17 +1507,17 @@ TEST_F(CollectAllTryWindowedTest, PartialFailure) { ...@@ -1507,17 +1507,17 @@ TEST_F(CollectAllTryWindowedTest, PartialFailure) {
auto results = folly::coro::blockingWait(folly::coro::collectAllTryWindowed( auto results = folly::coro::blockingWait(folly::coro::collectAllTryWindowed(
[]() -> folly::coro::Generator<folly::coro::Task<int>&&> { []() -> folly::coro::Generator<folly::coro::Task<int>&&> {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
co_yield [](int i) -> folly::coro::Task<int> { co_yield [](int idx) -> folly::coro::Task<int> {
using namespace std::literals::chrono_literals; using namespace std::literals::chrono_literals;
if (i == 3) { if (idx == 3) {
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorA{}; throw ErrorA{};
} else if (i == 7) { } else if (idx == 7) {
co_await folly::coro::co_reschedule_on_current_executor; co_await folly::coro::co_reschedule_on_current_executor;
throw ErrorB{}; throw ErrorB{};
} }
co_return i; co_return idx;
}(i); }(i);
} }
}(), }(),
...@@ -1562,7 +1562,7 @@ TEST_F(CollectAllTryWindowedTest, GeneratorFailure) { ...@@ -1562,7 +1562,7 @@ TEST_F(CollectAllTryWindowedTest, GeneratorFailure) {
[[maybe_unused]] auto results = folly::coro::blockingWait( [[maybe_unused]] auto results = folly::coro::blockingWait(
folly::coro::collectAllTryWindowed(generateTasks(), 5)); folly::coro::collectAllTryWindowed(generateTasks(), 5));
CHECK(false); CHECK(false);
} catch (ErrorA) { } catch (const ErrorA&) {
} }
// Even if the generator throws an exception we should still have launched // Even if the generator throws an exception we should still have launched
......
...@@ -32,7 +32,7 @@ using namespace std::chrono_literals; ...@@ -32,7 +32,7 @@ using namespace std::chrono_literals;
namespace { namespace {
struct SomeError : std::exception { struct SomeError : std::exception {
explicit SomeError(int value) : value(value) {} explicit SomeError(int v) : value(v) {}
int value; int value;
}; };
......
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