llvm-project/flang/unittests/Common/EnumClassTests.cpp
Andre Kuhlenschmidt bf60aa1c55
[flang][cli] Add diagnostic flags to the CLI (#142022)
This change allows the flang CLI to accept `-W[no-]<feature>` flags matching the clang syntax and enable and disable usage and language feature warnings.
2025-06-10 06:41:13 -07:00

35 lines
980 B
C++

//===-- flang/unittests/Common/FastIntSetTest.cpp ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "gtest/gtest.h"
#include "flang/Common/enum-class.h"
namespace Fortran::common {
ENUM_CLASS(TestEnum, One, Two, Three)
TEST(EnumClassTest, EnumToString) {
ASSERT_EQ(EnumToString(TestEnum::One), "One");
ASSERT_EQ(EnumToString(TestEnum::Two), "Two");
ASSERT_EQ(EnumToString(TestEnum::Three), "Three");
}
TEST(EnumClassTest, EnumClassForEach) {
std::string result;
bool first{true};
ForEachTestEnum([&](auto e) {
if (!first) {
result += ", ";
}
result += EnumToString(e);
first = false;
});
ASSERT_EQ(result, "One, Two, Three");
}
} // namespace Fortran::common