| 1 | //===-- SpecialMembersTests.cpp -------------------------------------------===// |
| 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 "TweakTesting.h" |
| 10 | #include "gtest/gtest.h" |
| 11 | |
| 12 | namespace clang { |
| 13 | namespace clangd { |
| 14 | namespace { |
| 15 | |
| 16 | TWEAK_TEST(SpecialMembers); |
| 17 | |
| 18 | TEST_F(SpecialMembersTest, Test) { |
| 19 | EXPECT_AVAILABLE("struct ^S {};" ); |
| 20 | EXPECT_UNAVAILABLE("struct S { ^ };" ); |
| 21 | EXPECT_UNAVAILABLE("union ^U {};" ); |
| 22 | EXPECT_AVAILABLE("struct ^S { S(const S&); S(S&&); };" ); |
| 23 | EXPECT_UNAVAILABLE("struct ^S {" |
| 24 | "S(const S&); S(S&&);" |
| 25 | "S &operator=(S&&); S &operator=(const S&);" |
| 26 | "};" ); |
| 27 | |
| 28 | const char *Output = R"cpp(struct S{S(const S&) = default; |
| 29 | S(S&&) = default; |
| 30 | S &operator=(const S&) = default; |
| 31 | S &operator=(S&&) = default; |
| 32 | };)cpp" ; |
| 33 | EXPECT_EQ(apply("struct ^S{};" ), Output); |
| 34 | |
| 35 | Output = R"cpp(struct S{S(const S&) = default; |
| 36 | S(S&&) = default; |
| 37 | S &operator=(const S&) = delete; |
| 38 | S &operator=(S&&) = delete; |
| 39 | int& ref;};)cpp" ; |
| 40 | EXPECT_EQ(apply("struct ^S{int& ref;};" ), Output); |
| 41 | } |
| 42 | |
| 43 | } // namespace |
| 44 | } // namespace clangd |
| 45 | } // namespace clang |
| 46 | |