[NFC][RISCV] Remove CFIIndex argument from allocateStack (#117871)
[llvm-project.git] / clang-tools-extra / clangd / unittests / tweaks / ScopifyEnumTests.cpp
blob5da059faaf5e8c2dcc8990cd6f42282413320117
1 //===-- DefineOutline.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 //===----------------------------------------------------------------------===//
9 #include "TweakTesting.h"
10 #include "gtest/gtest.h"
12 namespace clang::clangd {
13 namespace {
15 TWEAK_TEST(ScopifyEnum);
17 TEST_F(ScopifyEnumTest, TriggersOnUnscopedEnumDecl) {
18 FileName = "Test.hpp";
19 // Not available for scoped enum.
20 EXPECT_UNAVAILABLE(R"cpp(enum class ^E { V };)cpp");
22 // Not available for non-definition.
23 EXPECT_UNAVAILABLE(R"cpp(
24 enum E { V };
25 enum ^E;
26 )cpp");
29 TEST_F(ScopifyEnumTest, ApplyTestWithPrefix) {
30 std::string Original = R"cpp(
31 enum ^E { EV1, EV2, EV3 };
32 enum E;
33 E func(E in)
35 E out = EV1;
36 if (in == EV2)
37 out = E::EV3;
38 return out;
40 )cpp";
41 std::string Expected = R"cpp(
42 enum class E { V1, V2, V3 };
43 enum class E;
44 E func(E in)
46 E out = E::V1;
47 if (in == E::V2)
48 out = E::V3;
49 return out;
51 )cpp";
52 FileName = "Test.cpp";
53 SCOPED_TRACE(Original);
54 EXPECT_EQ(apply(Original), Expected);
57 TEST_F(ScopifyEnumTest, ApplyTestWithPrefixAndUnderscore) {
58 std::string Original = R"cpp(
59 enum ^E { E_V1, E_V2, E_V3 };
60 enum E;
61 E func(E in)
63 E out = E_V1;
64 if (in == E_V2)
65 out = E::E_V3;
66 return out;
68 )cpp";
69 std::string Expected = R"cpp(
70 enum class E { V1, V2, V3 };
71 enum class E;
72 E func(E in)
74 E out = E::V1;
75 if (in == E::V2)
76 out = E::V3;
77 return out;
79 )cpp";
80 FileName = "Test.cpp";
81 SCOPED_TRACE(Original);
82 EXPECT_EQ(apply(Original), Expected);
85 TEST_F(ScopifyEnumTest, ApplyTestWithoutPrefix) {
86 std::string Original = R"cpp(
87 enum ^E { V1, V2, V3 };
88 enum E;
89 E func(E in)
91 E out = V1;
92 if (in == V2)
93 out = E::V3;
94 return out;
96 )cpp";
97 std::string Expected = R"cpp(
98 enum class E { V1, V2, V3 };
99 enum class E;
100 E func(E in)
102 E out = E::V1;
103 if (in == E::V2)
104 out = E::V3;
105 return out;
107 )cpp";
108 FileName = "Test.cpp";
109 SCOPED_TRACE(Original);
110 EXPECT_EQ(apply(Original), Expected);
113 } // namespace
114 } // namespace clang::clangd