brintos

brintos / llvm-project-archived public Read only

0
0
Text · 980 B · eafba54 Raw
35 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "gtest/gtest.h"10#include "flang/Common/enum-class.h"11 12namespace Fortran::common {13 14ENUM_CLASS(TestEnum, One, Two, Three)15 16TEST(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 22TEST(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::common35