summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/coro/detached
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-10-04 12:03:32 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-10-06 14:11:25 +0000
commit2743ff3bc794ccdd276800a0f98050fbe8f346d3 (patch)
tree5071d3528dcf05358c6fff1b4c0c3dd7d4711324 /vespalib/src/tests/coro/detached
parent51e61ab17c38d01981a08527ad5a698beeb14411 (diff)
experiment with coroutines
Diffstat (limited to 'vespalib/src/tests/coro/detached')
-rw-r--r--vespalib/src/tests/coro/detached/CMakeLists.txt9
-rw-r--r--vespalib/src/tests/coro/detached/detached_test.cpp19
2 files changed, 28 insertions, 0 deletions
diff --git a/vespalib/src/tests/coro/detached/CMakeLists.txt b/vespalib/src/tests/coro/detached/CMakeLists.txt
new file mode 100644
index 00000000000..237b8615fec
--- /dev/null
+++ b/vespalib/src/tests/coro/detached/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalib_detached_test_app TEST
+ SOURCES
+ detached_test.cpp
+ DEPENDS
+ vespalib
+ GTest::GTest
+)
+vespa_add_test(NAME vespalib_detached_test_app COMMAND vespalib_detached_test_app)
diff --git a/vespalib/src/tests/coro/detached/detached_test.cpp b/vespalib/src/tests/coro/detached/detached_test.cpp
new file mode 100644
index 00000000000..f23d16cc75c
--- /dev/null
+++ b/vespalib/src/tests/coro/detached/detached_test.cpp
@@ -0,0 +1,19 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include <vespa/vespalib/coro/detached.h>
+#include <vespa/vespalib/gtest/gtest.h>
+
+using vespalib::coro::Detached;
+
+Detached set_result(int &res, int value) {
+ res = value;
+ co_return;
+}
+
+TEST(DetachedTest, call_detached_coroutine) {
+ int result = 0;
+ set_result(result, 42);
+ EXPECT_EQ(result, 42);
+}
+
+GTEST_MAIN_RUN_ALL_TESTS()