Store the result of expect completion tests on the heap

This commit is contained in:
Denis Blank 2017-03-03 13:34:09 +01:00
parent 05b611ce78
commit bf4335d602
2 changed files with 27 additions and 12 deletions

View File

@ -42,10 +42,10 @@ inline namespace abi_v1 {
namespace detail {
namespace testing {
template <typename C> void expect_async_completion(C&& continuable) {
bool called = false;
std::forward<C>(continuable).then([&](auto&&... args) {
ASSERT_FALSE(called);
called = true;
auto called = std::make_shared<bool>(false);
std::forward<C>(continuable).then([called](auto&&... args) {
ASSERT_FALSE(*called);
*called = true;
// Workaround for our known GCC bug.
util::unused(std::forward<decltype(args)>(args)...);

View File

@ -58,21 +58,36 @@ template <typename T> auto assert_invocation(T* me) {
[](auto&& /*callback*/) mutable { FAIL(); });
}
TYPED_TEST(single_dimension_tests, are_incomplete_when_released) {
auto chain = this->supply();
chain.release();
EXPECT_ASYNC_INCOMPLETE(std::move(chain));
TYPED_TEST(single_dimension_tests, are_incomplete_when_frozen) {
{
auto chain = this->supply();
chain.freeze();
EXPECT_ASYNC_INCOMPLETE(std::move(chain));
}
{
auto chain = this->supply();
chain.freeze();
EXPECT_ASYNC_INCOMPLETE(std::move(chain).then(this->supply()));
}
}
TYPED_TEST(single_dimension_tests, are_not_dispatched_when_released) {
TYPED_TEST(single_dimension_tests, are_not_dispatched_when_frozen) {
auto chain = assert_invocation(this);
chain.release();
chain.freeze();
EXPECT_ASYNC_INCOMPLETE(std::move(chain));
}
TYPED_TEST(single_dimension_tests, are_not_finished_when_not_continued) {
auto chain = create_incomplete(this);
EXPECT_ASYNC_INCOMPLETE(std::move(chain));
{
auto chain = create_incomplete(this);
EXPECT_ASYNC_INCOMPLETE(std::move(chain));
}
{
auto chain = create_incomplete(this);
EXPECT_ASYNC_INCOMPLETE(std::move(chain).then(this->supply()));
}
}
TYPED_TEST(single_dimension_tests, are_chainable) {