summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 581d15672ba..1ab1cb5d151 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6901,6 +6901,74 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
Spaces);
verifyFormat("Deleted &operator=( const Deleted & ) &;", Spaces);
verifyFormat("SomeType MemberFunction( const Deleted & ) &;", Spaces);
+
+ FormatStyle BreakTemplate = getLLVMStyle();
+ BreakTemplate.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int &foo(const std::string &str) & noexcept {}\n"
+ "};",
+ BreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int &foo(const std::string &str) && noexcept {}\n"
+ "};",
+ BreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int &foo(const std::string &str) const & noexcept {}\n"
+ "};",
+ BreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int &foo(const std::string &str) const & noexcept {}\n"
+ "};",
+ BreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " auto foo(const std::string &str) && noexcept -> int & {}\n"
+ "};",
+ BreakTemplate);
+
+ FormatStyle AlignLeftBreakTemplate = getLLVMStyle();
+ AlignLeftBreakTemplate.AlwaysBreakTemplateDeclarations =
+ FormatStyle::BTDS_Yes;
+ AlignLeftBreakTemplate.PointerAlignment = FormatStyle::PAS_Left;
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int& foo(const std::string& str) & noexcept {}\n"
+ "};",
+ AlignLeftBreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int& foo(const std::string& str) && noexcept {}\n"
+ "};",
+ AlignLeftBreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int& foo(const std::string& str) const & noexcept {}\n"
+ "};",
+ AlignLeftBreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " int& foo(const std::string& str) const & noexcept {}\n"
+ "};",
+ AlignLeftBreakTemplate);
+
+ verifyFormat("struct f {\n"
+ " template <class T>\n"
+ " auto foo(const std::string& str) && noexcept -> int& {}\n"
+ "};",
+ AlignLeftBreakTemplate);
}
TEST_F(FormatTest, UnderstandsNewAndDelete) {
OpenPOWER on IntegriCloud