Newer
Older
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef MANTID_KERNEL_OPTIONALBOOLTEST_H_
#define MANTID_KERNEL_OPTIONALBOOLTEST_H_
#include <cxxtest/TestSuite.h>
#include "MantidKernel/OptionalBool.h"
using namespace Mantid::Kernel;
class OptionalBoolTest : public CxxTest::TestSuite {
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static OptionalBoolTest *createSuite() { return new OptionalBoolTest(); }
static void destroySuite(OptionalBoolTest *suite) { delete suite; }
void test_construction_by_bool() {
OptionalBool arg1(true);
TS_ASSERT_EQUALS(OptionalBool::True, arg1.getValue());
OptionalBool arg2(false);
TS_ASSERT_EQUALS(OptionalBool::False, arg2.getValue());
}
void test_defaults_to_unset() {
OptionalBool arg;
TS_ASSERT_EQUALS(OptionalBool::Unset, arg.getValue());
}
void test_construction_by_value() {
auto value = OptionalBool::True;
OptionalBool arg(value);
TS_ASSERT_EQUALS(value, arg.getValue());
}
void test_comparison_overload() {
OptionalBool a(OptionalBool::True);
OptionalBool b(OptionalBool::True);
TS_ASSERT_EQUALS(a, b);
OptionalBool c(OptionalBool::False);
TS_ASSERT_DIFFERS(a, c);
OptionalBool d(OptionalBool::Unset);
TS_ASSERT_DIFFERS(a, d);
}
void test_copy_constructor() {
OptionalBool arg(OptionalBool::False);
OptionalBool copy(arg);
TS_ASSERT_EQUALS(OptionalBool::False, copy.getValue());
}
void test_assignment() {
OptionalBool arg(OptionalBool::False);
arg = OptionalBool(OptionalBool::True);
TS_ASSERT_EQUALS(OptionalBool::True, arg.getValue());
}
};
#endif /* MANTID_KERNEL_OPTIONALBOOLTEST_H_ */