blob: 6d989070e035b5ab61da63a3a4875890aa36cd0f (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/runnable_pair.h>
using namespace vespalib;
struct Add : public Runnable {
int &val;
Add(int &v) : val(v) {}
void run() override { val += 10; }
};
struct Mul : public Runnable {
int &val;
Mul(int &v) : val(v) {}
void run() override { val *= 10; }
};
TEST("require that runnable pair runs runnables in order") {
int value = 0;
Add add(value);
Mul mul(value);
RunnablePair pair(add, mul);
EXPECT_EQUAL(0, value);
pair.run();
EXPECT_EQUAL(100, value);
}
TEST_MAIN() { TEST_RUN_ALL(); }
|