1 | //===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- C++ -*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "gtest/gtest.h" |
10 | #include "flang/Common/enum-class.h" |
11 | |
12 | namespace Fortran::common { |
13 | |
14 | ENUM_CLASS(TestEnum, One, Two, Three) |
15 | |
16 | TEST(EnumClassTest, EnumToString) { |
17 | ASSERT_EQ(EnumToString(TestEnum::One), "One"); |
18 | ASSERT_EQ(EnumToString(TestEnum::Two), "Two"); |
19 | ASSERT_EQ(EnumToString(TestEnum::Three), "Three"); |
20 | } |
21 | |
22 | TEST(EnumClassTest, EnumClassForEach) { |
23 | std::string result; |
24 | bool first{true}; |
25 | ForEachTestEnum([&](auto e) { |
26 | if (!first) { |
27 | result += ", "; |
28 | } |
29 | result += EnumToString(e); |
30 | first = false; |
31 | }); |
32 | ASSERT_EQ(result, "One, Two, Three"); |
33 | } |
34 | } // namespace Fortran::common |
35 |