Skip to content

Commit 4fc5b5a

Browse files
committed
Adding some more tests.
1 parent bd3ac04 commit 4fc5b5a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/test_coroutines.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,49 @@ TEST_CASE("testing the Coroutine class")
5353
CHECK(coroutine.done());
5454
}
5555

56+
Coroutine<>
57+
CoroutineVoidTest()
58+
{
59+
co_await std::suspend_always{};
60+
}
61+
62+
TEST_CASE("testing the Coroutine class with void")
63+
{
64+
auto coroutine = CoroutineVoidTest();
65+
66+
unsigned rounds = 0;
67+
while (!coroutine.done()) {
68+
coroutine.resume();
69+
rounds++;
70+
}
71+
72+
CHECK(rounds == 2);
73+
CHECK(coroutine.done());
74+
}
75+
76+
Coroutine<int>
77+
CascadeCoroutines()
78+
{
79+
co_await CoroutineVoidTest();
80+
auto result = co_await CoroutineTest();
81+
co_return result;
82+
}
83+
84+
TEST_CASE("testing the Coroutine class with cascading coroutines")
85+
{
86+
auto coroutine = CascadeCoroutines();
87+
88+
unsigned rounds = 0;
89+
while (!coroutine.done()) {
90+
coroutine.resume();
91+
rounds++;
92+
}
93+
94+
auto result = coroutine.value();
95+
96+
CHECK(rounds == 4);
97+
CHECK(result == 42);
98+
CHECK(coroutine.done());
99+
}
100+
56101
} // namespace triton::perfanalyzer

0 commit comments

Comments
 (0)