diff options
author | Manuel Klimek <klimek@google.com> | 2013-01-06 20:07:31 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-01-06 20:07:31 +0000 |
commit | a5342db6fcc6ee3fae084f584ecb019726de9cca (patch) | |
tree | e28f4727b138527bca6a83505a47cbf4eb448c32 /unittests/Format/FormatTest.cpp | |
parent | 1834a048052e95195b71b6fa9189ecaf00e7d10d (diff) |
Fixes handling of unbalances braces.
If we find an unexpected closing brace, we must not stop parsing, as
we'd otherwise not layout anything beyond that point.
If we find a structural error on the highest level we'll not re-indent
anyway, but we'll still want to format within unwrapped lines.
Needed to introduce a differentiation between an expected and unexpected
closing brace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171666 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 8d95538b16..28f63aa055 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -474,8 +474,12 @@ TEST_F(FormatTest, FormatHashIfNotAtStartOfLine) { verifyFormat("{\n {\n a #c;\n }\n}"); } -// FIXME: write test for unbalanced braces in macros... -// FIXME: test # inside a normal statement (like {#define A b}) +TEST_F(FormatTest, FormatUnbalancedStructuralElements) { + EXPECT_EQ("#define A \\\n { \\\n {\nint i;", + format("#define A { {\nint i;", getLLVMStyleWithColumns(11))); + EXPECT_EQ("#define A \\\n } \\\n }\nint i;", + format("#define A } }\nint i;", getLLVMStyleWithColumns(11))); +} TEST_F(FormatTest, MixingPreprocessorDirectivesAndNormalCode) { EXPECT_EQ( |