forked from frc971/971-Robot-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.cc
56 lines (46 loc) · 1.83 KB
/
options_test.cc
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
#include "aos/util/options.h"
#include <memory>
#include "gtest/gtest.h"
namespace aos::testing {
class OptionsTest : public ::testing::Test {
public:
static constexpr Options<OptionsTest>::Option kOne{1}, kTwo{2}, kThree{4},
kFour{8};
};
constexpr Options<OptionsTest>::Option OptionsTest::kOne, OptionsTest::kTwo,
OptionsTest::kThree, OptionsTest::kFour;
TEST_F(OptionsTest, Basic) {
const Options<OptionsTest> one_three = kOne | kThree;
EXPECT_TRUE(one_three & kOne);
EXPECT_FALSE(one_three & kTwo);
EXPECT_TRUE(one_three & kThree);
}
TEST_F(OptionsTest, NoOthersSet) {
const Options<OptionsTest> one_three = kOne | kThree;
EXPECT_TRUE(one_three.NoOthersSet(one_three));
EXPECT_TRUE(one_three.NoOthersSet(kOne | kTwo | kThree));
EXPECT_TRUE(one_three.NoOthersSet(kOne | kThree | kFour));
EXPECT_TRUE(one_three.NoOthersSet(kOne | kTwo | kThree | kFour));
EXPECT_FALSE(one_three.NoOthersSet(kOne));
EXPECT_FALSE(one_three.NoOthersSet(kThree));
EXPECT_FALSE(one_three.NoOthersSet(kTwo | kFour));
}
TEST_F(OptionsTest, ExactlyOneSet) {
const Options<OptionsTest> one_three = kOne | kThree;
EXPECT_TRUE(one_three.ExactlyOneSet(kOne | kTwo));
EXPECT_FALSE(one_three.ExactlyOneSet(one_three));
EXPECT_TRUE(one_three.ExactlyOneSet(kTwo | kThree | kFour));
EXPECT_FALSE(one_three.ExactlyOneSet(kOne | kTwo | kThree | kFour));
}
TEST_F(OptionsTest, AllSet) {
const Options<OptionsTest> one_three = kOne | kThree;
EXPECT_TRUE(one_three.AllSet(one_three));
EXPECT_TRUE(one_three.AllSet(kOne));
EXPECT_FALSE(one_three.AllSet(kTwo));
EXPECT_TRUE(one_three.AllSet(kThree));
EXPECT_FALSE(one_three.AllSet(kFour));
EXPECT_FALSE(one_three.AllSet(kOne | kTwo | kFour));
EXPECT_FALSE(one_three.AllSet(kTwo | kThree | kFour));
EXPECT_FALSE(one_three.AllSet(kOne | kTwo | kThree | kFour));
}
} // namespace aos::testing