[clang-format] Add tests for spacing between ref-qualifier and `noexcept`. NFC.

Cf. https://github.com/llvm/llvm-project/issues/44542.
Cf. ae1b7859cb.
This commit is contained in:
Marek Kurdej 2022-02-11 10:49:53 +01:00
parent abc873694f
commit a218706cba
1 changed files with 31 additions and 0 deletions

View File

@ -9589,8 +9589,11 @@ TEST_F(FormatTest, UnderstandsOverloadedOperators) {
}
TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
verifyFormat("void A::b() && {}");
verifyFormat("void A::b() &&noexcept {}");
verifyFormat("Deleted &operator=(const Deleted &) & = default;");
verifyFormat("Deleted &operator=(const Deleted &) && = delete;");
verifyFormat("Deleted &operator=(const Deleted &) &noexcept = default;");
verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;");
verifyFormat("SomeType MemberFunction(const Deleted &) && = delete;");
verifyFormat("Deleted &operator=(const Deleted &) &;");
@ -9600,8 +9603,10 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
verifyFormat("SomeType MemberFunction(const Deleted &) &&noexcept {}");
verifyFormat("void Fn(T const &) const &;");
verifyFormat("void Fn(T const volatile &&) const volatile &&;");
verifyFormat("void Fn(T const volatile &&) const volatile &&noexcept;");
verifyFormat("template <typename T>\n"
"void F(T) && = delete;",
getGoogleStyle());
@ -9609,7 +9614,10 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
FormatStyle AlignLeft = getLLVMStyle();
AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("void A::b() && {}", AlignLeft);
verifyFormat("void A::b() && noexcept {}", AlignLeft);
verifyFormat("Deleted& operator=(const Deleted&) & = default;", AlignLeft);
verifyFormat("Deleted& operator=(const Deleted&) & noexcept = default;",
AlignLeft);
verifyFormat("SomeType MemberFunction(const Deleted&) & = delete;",
AlignLeft);
verifyFormat("Deleted& operator=(const Deleted&) &;", AlignLeft);
@ -9620,6 +9628,29 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
verifyFormat("auto Function(T) & -> void;", AlignLeft);
verifyFormat("void Fn(T const&) const&;", AlignLeft);
verifyFormat("void Fn(T const volatile&&) const volatile&&;", AlignLeft);
verifyFormat("void Fn(T const volatile&&) const volatile&& noexcept;",
AlignLeft);
FormatStyle AlignMiddle = getLLVMStyle();
AlignMiddle.PointerAlignment = FormatStyle::PAS_Middle;
verifyFormat("void A::b() && {}", AlignMiddle);
verifyFormat("void A::b() && noexcept {}", AlignMiddle);
verifyFormat("Deleted & operator=(const Deleted &) & = default;",
AlignMiddle);
verifyFormat("Deleted & operator=(const Deleted &) & noexcept = default;",
AlignMiddle);
verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;",
AlignMiddle);
verifyFormat("Deleted & operator=(const Deleted &) &;", AlignMiddle);
verifyFormat("SomeType MemberFunction(const Deleted &) &;", AlignMiddle);
verifyFormat("auto Function(T t) & -> void {}", AlignMiddle);
verifyFormat("auto Function(T... t) & -> void {}", AlignMiddle);
verifyFormat("auto Function(T) & -> void {}", AlignMiddle);
verifyFormat("auto Function(T) & -> void;", AlignMiddle);
verifyFormat("void Fn(T const &) const &;", AlignMiddle);
verifyFormat("void Fn(T const volatile &&) const volatile &&;", AlignMiddle);
verifyFormat("void Fn(T const volatile &&) const volatile && noexcept;",
AlignMiddle);
FormatStyle Spaces = getLLVMStyle();
Spaces.SpacesInCStyleCastParentheses = true;