summaryrefslogtreecommitdiffstats
path: root/tests/auto/basic/tst_basic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/basic/tst_basic.cpp')
-rw-r--r--tests/auto/basic/tst_basic.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/basic/tst_basic.cpp b/tests/auto/basic/tst_basic.cpp
new file mode 100644
index 0000000..c33ef40
--- /dev/null
+++ b/tests/auto/basic/tst_basic.cpp
@@ -0,0 +1,37 @@
+#include <QtTest/QtTest>
+#include <coroutine.h>
+
+class tst_basic : public QObject
+{
+Q_OBJECT
+
+private slots:
+ void noYield();
+};
+
+class NoYieldCoro : public Coroutine
+{
+public:
+ virtual void run()
+ {
+ i++;
+ QCOMPARE(status(), Running);
+ QCOMPARE(currentCoroutine(), this);
+ }
+
+ int i;
+};
+
+void tst_basic::noYield()
+{
+ NoYieldCoro coro;
+ coro.i = 0;
+ QCOMPARE(coro.status(), Coroutine::NotStarted);
+ QCOMPARE(coro.cont(), false);
+ QCOMPARE(coro.i, 1);
+ QCOMPARE(coro.status(), Coroutine::Terminated);
+ Q_ASSERT(Coroutine::currentCoroutine() != &coro);
+}
+
+QTEST_MAIN(tst_basic)
+#include "tst_basic.moc"