summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/executor/executor_test.cpp
blob: c508417e1c27f7170d00fa973d9e478082aefb4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/closuretask.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() {
    bool called = false;
    Executor::Task::UP task = makeTask(makeClosure(setBool, &called));
    EXPECT_TRUE(!called);
    task->run();
    EXPECT_TRUE(called);
}

}  // namespace

TEST_APPHOOK(Test);