aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-10-29 14:52:02 +0000
committerDaniel Jasper <djasper@google.com>2013-10-29 14:52:02 +0000
commitd8ee5c1c8709c5fc060a48b598112f6eadb35d96 (patch)
tree939d84eb71e58c2ed25c169d72e6c66fe9e04740 /unittests/Format
parentb7488d77414b000ce2506b520a6b29f845fb3950 (diff)
downloadclang-d8ee5c1c8709c5fc060a48b598112f6eadb35d96.tar.gz
clang-format: Option to control spacing in template argument lists.
Same as SpacesInParentheses, this option allows adding a space inside the '<' and '>' of a template parameter list. Patch by Christopher Olsen. This fixes llvm.org/PR17301. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format')
-rw-r--r--unittests/Format/FormatTest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 83035f72bc..991763cdf7 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -6592,6 +6592,7 @@ TEST_F(FormatTest, ParsesConfiguration) {
CHECK_PARSE_BOOL(Cpp11BracedListStyle);
CHECK_PARSE_BOOL(IndentFunctionDeclarationAfterType);
CHECK_PARSE_BOOL(SpacesInParentheses);
+ CHECK_PARSE_BOOL(SpacesInAngles);
CHECK_PARSE_BOOL(SpaceInEmptyParentheses);
CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
CHECK_PARSE_BOOL(SpaceAfterControlStatementKeyword);
@@ -7010,5 +7011,30 @@ TEST_F(FormatTest, ConfigurableContinuationIndentWidth) {
format("int i = longFunction(arg);", SixIndent));
}
+TEST_F(FormatTest, SpacesInAngles) {
+ FormatStyle Spaces = getLLVMStyle();
+ Spaces.SpacesInAngles = true;
+
+ verifyFormat("static_cast< int >(arg);", Spaces);
+ verifyFormat("template < typename T0, typename T1 > void f() {}", Spaces);
+ verifyFormat("f< int, float >();", Spaces);
+ verifyFormat("template <> g() {}", Spaces);
+ verifyFormat("template < std::vector< int > > f() {}", Spaces);
+
+ Spaces.Standard = FormatStyle::LS_Cpp03;
+ Spaces.SpacesInAngles = true;
+ verifyFormat("A< A< int > >();", Spaces);
+
+ Spaces.SpacesInAngles = false;
+ verifyFormat("A<A<int> >();", Spaces);
+
+ Spaces.Standard = FormatStyle::LS_Cpp11;
+ Spaces.SpacesInAngles = true;
+ verifyFormat("A< A< int > >();", Spaces);
+
+ Spaces.SpacesInAngles = false;
+ verifyFormat("A<A<int>>();", Spaces);
+}
+
} // end namespace tooling
} // end namespace clang