Debian Codegraph @

llvm-project/clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp

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