src/base/coroutine.test.cc
/**
 * This test is checking the yielding interface of a coroutine
 * which takes no argument and returns integers.
 * Coroutine::get() and CallerType::operator() are the tested
 * APIS.
 */
This test is checking the yielding interface of a coroutine
which takes no argument and returns integers.
Coroutine::get() and CallerType::operator() are the tested
APIS.
This test is checking the yielding interface of a coroutine which takes no argument and returns integers . Coroutine :: get () and CallerType :: operator () are the tested APIS .
TEST(Coroutine, Returning)
{
    const std::vector<int> output{ 1, 2, 3 };
    const std::vector<int> expected_values = output;
    auto returning_task =
    [&output] (Coroutine<void, int>::CallerType& yield)
    {
        for (const auto ret : output) {
            yield(ret);
        }
    };
    Coroutine<void, int> coro(returning_task);
    ASSERT_TRUE(coro);
    for (const auto expected : expected_values) {
        int returned = coro.get();
        ASSERT_EQ(returned, expected);
    }
}
TEST ( Coroutine , Returning ) { const std :: vector < int > output { 1 , 2 , 3 } ; const std :: vector < int > expected_values = output ; auto returning_task = [ & output ] ( Coroutine < void , int > :: CallerType & yield ) { for ( const auto ret : output ) { yield ( ret ) ; } } ; Coroutine < void , int > coro ( returning_task ) ; ASSERT_TRUE ( coro ) ; for ( const auto expected : expected_values ) { int returned = coro . get ( ) ; ASSERT_EQ ( returned , expected ) ; } }
This test is checking the yielding interface of a coroutine
 which takes no argument and returns integers.
This test is checking the yielding interface of a coroutine which takes no argument and returns integers .