File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments