Commit e195d5c3 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

refactor to avoid compiler crash

Summary:
g++ 8.2.1 on some platforms crashes on the gtests defined
in EventBaseTestLib.h that declare inner classes.  This diff
refactors the tests so that they can be successfully compiled.

Reviewed By: yfeldblum

Differential Revision: D19871529

fbshipit-source-id: 3e84c2983e90b7445c014c002bbac504e0366657
parent 839ce2a7
......@@ -840,23 +840,25 @@ TYPED_TEST_P(EventBaseTest, WritePartial) {
}
}
namespace {
class DestroyHandler : public AsyncTimeout {
public:
DestroyHandler(EventBase* eb, EventHandler* h)
: AsyncTimeout(eb), handler_(h) {}
void timeoutExpired() noexcept override {
delete handler_;
}
private:
EventHandler* handler_;
};
} // namespace
/**
* Test destroying a registered EventHandler
*/
TYPED_TEST_P(EventBaseTest, DestroyHandler) {
class DestroyHandler : public AsyncTimeout {
public:
DestroyHandler(EventBase* eb, EventHandler* h)
: AsyncTimeout(eb), handler_(h) {}
void timeoutExpired() noexcept override {
delete handler_;
}
private:
EventHandler* handler_;
};
TYPED_TEST_P(EventBaseTest, DestroyingHandler) {
FOLLY_SKIP_IF_NULLPTR_BACKEND(eb);
SocketPair sp;
......@@ -1115,23 +1117,25 @@ TYPED_TEST_P(EventBaseTest, CancelTimeout) {
T_CHECK_TIMEOUT(start, end, std::chrono::milliseconds(50));
}
namespace {
class DestroyTimeout : public AsyncTimeout {
public:
DestroyTimeout(EventBase* eb, AsyncTimeout* t)
: AsyncTimeout(eb), timeout_(t) {}
void timeoutExpired() noexcept override {
delete timeout_;
}
private:
AsyncTimeout* timeout_;
};
} // namespace
/**
* Test destroying a scheduled timeout object
*/
TYPED_TEST_P(EventBaseTest, DestroyTimeout) {
class DestroyTimeout : public AsyncTimeout {
public:
DestroyTimeout(EventBase* eb, AsyncTimeout* t)
: AsyncTimeout(eb), timeout_(t) {}
void timeoutExpired() noexcept override {
delete timeout_;
}
private:
AsyncTimeout* timeout_;
};
TYPED_TEST_P(EventBaseTest, DestroyingTimeout) {
FOLLY_SKIP_IF_NULLPTR_BACKEND(eb);
TestTimeout* t1 = new TestTimeout(&eb);
......@@ -2295,14 +2299,14 @@ REGISTER_TYPED_TEST_CASE_P(
ReadWritePersist,
ReadPartial,
WritePartial,
DestroyHandler,
DestroyingHandler,
RunAfterDelay,
RunAfterDelayDestruction,
BasicTimeouts,
ReuseTimeout,
RescheduleTimeout,
CancelTimeout,
DestroyTimeout,
DestroyingTimeout,
ScheduledFn,
ScheduledFnAt,
RunInThread,
......
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