diff options
-rw-r--r-- | vespalib/src/tests/executor/executor_test.cpp | 33 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/lambdatask.h (renamed from staging_vespalib/src/vespa/vespalib/util/lambdatask.h) | 2 |
2 files changed, 12 insertions, 23 deletions
diff --git a/vespalib/src/tests/executor/executor_test.cpp b/vespalib/src/tests/executor/executor_test.cpp index c508417e1c2..9015391beaa 100644 --- a/vespalib/src/tests/executor/executor_test.cpp +++ b/vespalib/src/tests/executor/executor_test.cpp @@ -2,30 +2,13 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/util/closuretask.h> +#include <vespa/vespalib/util/lambdatask.h> using namespace vespalib; -namespace { - -class Test : public vespalib::TestApp { - void requireThatClosuresCanBeWrappedInATask(); - -public: - int Main() override; -}; - -int -Test::Main() -{ - TEST_INIT("executor_test"); - - TEST_DO(requireThatClosuresCanBeWrappedInATask()); - - TEST_DONE(); -} - void setBool(bool *b) { *b = true; } -void Test::requireThatClosuresCanBeWrappedInATask() { + +TEST("require that closures can be wrapped as tasks") { bool called = false; Executor::Task::UP task = makeTask(makeClosure(setBool, &called)); EXPECT_TRUE(!called); @@ -33,6 +16,12 @@ void Test::requireThatClosuresCanBeWrappedInATask() { EXPECT_TRUE(called); } -} // namespace +TEST("require that lambdas can be wrapped as tasks") { + bool called = false; + Executor::Task::UP task = makeLambdaTask([&called]() { called = true; }); + EXPECT_TRUE(!called); + task->run(); + EXPECT_TRUE(called); +} -TEST_APPHOOK(Test); +TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/staging_vespalib/src/vespa/vespalib/util/lambdatask.h b/vespalib/src/vespa/vespalib/util/lambdatask.h index 1d85c1a0e31..35543407aaa 100644 --- a/staging_vespalib/src/vespa/vespalib/util/lambdatask.h +++ b/vespalib/src/vespa/vespalib/util/lambdatask.h @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/util/executor.h> +#include "executor.h" namespace vespalib { |