1 /**
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "util/flags.h"
17
18 #include <gtest/gtest.h>
19
20 namespace panda::verifier::test {
21
TEST(VerifierTest_FlagsForEnum,simple)22 TEST(VerifierTest_FlagsForEnum, simple)
23 {
24 enum class Enum { E1, E2, E3 };
25 using F = panda::verifier::FlagsForEnum<size_t, Enum, Enum::E1, Enum::E2, Enum::E3>;
26 F flags;
27
28 flags[Enum::E2] = true;
29 EXPECT_TRUE(flags[Enum::E2]);
30 EXPECT_FALSE(flags[Enum::E1]);
31 EXPECT_FALSE(flags[Enum::E3]);
32 flags[Enum::E2] = false;
33 EXPECT_FALSE(flags[Enum::E1]);
34 EXPECT_FALSE(flags[Enum::E2]);
35 EXPECT_FALSE(flags[Enum::E3]);
36
37 flags[Enum::E2] = true;
38 flags[Enum::E1] = true;
39 EXPECT_TRUE(flags[Enum::E1]);
40 EXPECT_TRUE(flags[Enum::E2]);
41 EXPECT_FALSE(flags[Enum::E3]);
42 flags[Enum::E1] = false;
43 EXPECT_FALSE(flags[Enum::E1]);
44 EXPECT_TRUE(flags[Enum::E2]);
45 EXPECT_FALSE(flags[Enum::E3]);
46 }
47
48 } // namespace panda::verifier::test
49