src/base/coroutine.test.cc
/**
 * This test is testing nested coroutines by using one inner and one
 * outer coroutine. It basically ensures that yielding from the inner
 * coroutine returns to the outer coroutine (mid-layer of execution) and
 * not to the outer caller.
 */
This test is testing nested coroutines by using one inner and one
outer coroutine. It basically ensures that yielding from the inner
coroutine returns to the outer coroutine (mid-layer of execution) and
not to the outer caller.
This test is testing nested coroutines by using one inner and one outer coroutine . It basically ensures that yielding from the inner coroutine returns to the outer coroutine ( mid - layer of execution ) and not to the outer caller .
TEST(Coroutine, Nested)
{
    const std::string wrong("Inner");
    const std::string expected("Inner + Outer");
    auto inner_task =
    [] (Coroutine<void, std::string>::CallerType& yield)
    {
        std::string inner_string("Inner");
        yield(inner_string);
    };
    auto outer_task =
    [&inner_task] (Coroutine<void, std::string>::CallerType& yield)
    {
        Coroutine<void, std::string> coro(inner_task);
        std::string inner_string = coro.get();
        std::string outer_string("Outer");
        yield(inner_string + " + " + outer_string);
    };
    Coroutine<void, std::string> coro(outer_task);
    ASSERT_TRUE(coro);
    std::string result = coro.get();
    ASSERT_NE(result, wrong);
    ASSERT_EQ(result, expected);
}
TEST ( Coroutine , Nested ) { const std :: string wrong ( " " ) ; const std :: string expected ( " " ) ; auto inner_task = [ ] ( Coroutine < void , std :: string > :: CallerType & yield ) { std :: string inner_string ( " " ) ; yield ( inner_string ) ; } ; auto outer_task = [ & inner_task ] ( Coroutine < void , std :: string > :: CallerType & yield ) { Coroutine < void , std :: string > coro ( inner_task ) ; std :: string inner_string = coro . get ( ) ; std :: string outer_string ( " " ) ; yield ( inner_string + " " + outer_string ) ; } ; Coroutine < void , std :: string > coro ( outer_task ) ; ASSERT_TRUE ( coro ) ; std :: string result = coro . get ( ) ; ASSERT_NE ( result , wrong ) ; ASSERT_EQ ( result , expected ) ; }
This test is testing nested coroutines by using one inner and one
 outer coroutine.
This test is testing nested coroutines by using one inner and one outer coroutine .