Make syntax tree test print the line number when it fails
authorDmitri Gribenko <gribozavr@gmail.com>
Thu, 4 Jun 2020 08:35:43 +0000 (10:35 +0200)
committerDmitri Gribenko <gribozavr@gmail.com>
Thu, 4 Jun 2020 08:42:44 +0000 (10:42 +0200)
Summary:
The syntax tree test uses a helper function that executes all testing
assertions. When an assertion fails, the only line number that gets
printed to the log refers to the helper function. After this change, we
would also get the line number of the EXPECT_TRUE macro invocation
(unfortunately, the line number of the last token of it, not the first
one, but there's not much I can do about it).

Reviewers: hlopko, eduucaldas

Reviewed By: hlopko, eduucaldas

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81107

clang/unittests/Tooling/Syntax/TreeTest.cpp

index b8a188a..c7a2b14 100644 (file)
@@ -209,15 +209,22 @@ protected:
     return Root;
   }
 
-  void expectTreeDumpEqual(StringRef Code, StringRef Tree) {
+  ::testing::AssertionResult treeDumpEqual(StringRef Code, StringRef Tree) {
     SCOPED_TRACE(llvm::join(GetParam().getCommandLineArgs(), " "));
-    SCOPED_TRACE(Code);
 
     auto *Root = buildTree(Code, GetParam());
-    EXPECT_EQ(Diags->getClient()->getNumErrors(), 0u)
-        << "Source file has syntax errors, they were printed to the test log";
+    if (Diags->getClient()->getNumErrors() != 0) {
+      return ::testing::AssertionFailure()
+             << "Source file has syntax errors, they were printed to the test "
+                "log";
+    }
     std::string Actual = std::string(StringRef(Root->dump(*Arena)).trim());
+    // EXPECT_EQ shows the diff between the two strings if they are different.
     EXPECT_EQ(Tree.trim().str(), Actual);
+    if (Actual != Tree.trim().str()) {
+      return ::testing::AssertionFailure();
+    }
+    return ::testing::AssertionSuccess();
   }
 
   // Adds a file to the test VFS.
@@ -266,11 +273,11 @@ protected:
 };
 
 TEST_P(SyntaxTreeTest, Simple) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int main() {}
 void foo() {}
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -293,15 +300,15 @@ void foo() {}
   `-CompoundStatement
     |-{
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleVariable) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int a;
 int b = 42;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -317,14 +324,14 @@ int b = 42;
   | `-UnknownExpression
   |   `-42
   `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, SimpleFunction) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void foo(int a, int b) {}
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -346,17 +353,17 @@ void foo(int a, int b) {}
   `-CompoundStatement
     |-{
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int main() {
   if (1) {}
   if (1) {} else if (0) {}
 }
-        )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -397,11 +404,11 @@ int main() {
     |     |-{
     |     `-}
     `-}
-        )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test() {
   for (;;)  {}
@@ -428,21 +435,21 @@ void test() {
     |   |-{
     |   `-}
     `-}
-        )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test() {
   int a[3];
   for (int x : a)
     ;
 }
-      )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -479,12 +486,17 @@ void test() {
     | `-EmptyStatement
     |   `-;
     `-}
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  expectTreeDumpEqual("void test() { int a = 10; }",
-                      R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+      R"cpp(
+void test() {
+  int a = 10;
+}
+)cpp",
+      R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
@@ -505,11 +517,11 @@ TEST_P(SyntaxTreeTest, DeclarationStatement) {
     | |     `-10
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test() {
   switch (1) {
@@ -549,11 +561,11 @@ void test() {
     |   |     `-;
     |   `-}
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, While) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test() {
   while (1) { continue; break; }
@@ -586,15 +598,20 @@ void test() {
     |   | `-;
     |   `-}
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UnhandledStatement) {
   // Unhandled statements should end up as 'unknown statement'.
   // This example uses a 'label statement', which does not yet have a syntax
   // counterpart.
-  expectTreeDumpEqual("int main() { foo: return 100; }",
-                      R"txt(
+  EXPECT_TRUE(treeDumpEqual(
+      R"cpp(
+int main() {
+  foo: return 100;
+}
+)cpp",
+      R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
   |-int
@@ -614,19 +631,19 @@ TEST_P(SyntaxTreeTest, UnhandledStatement) {
     |   | `-100
     |   `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Expressions) {
   // expressions should be wrapped in 'ExpressionStatement' when they appear
   // in a statement position.
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test() {
   test();
   if (1) test(); else test();
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -667,19 +684,19 @@ void test() {
     |   | `-)
     |   `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, CxxNullPtrLiteral) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test() {
   nullptr;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -696,17 +713,17 @@ void test() {
     | | `-nullptr
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, PostfixUnaryOperator) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test(int a) {
   a++;
   a--;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -735,11 +752,11 @@ void test(int a) {
     | | `---
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, PrefixUnaryOperator) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test(int a, int *ap) {
   --a; ++a;
@@ -751,7 +768,7 @@ void test(int a, int *ap) {
   !a;
   __real a; __imag a;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -834,20 +851,20 @@ void test(int a, int *ap) {
     | |   `-a
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, PrefixUnaryOperatorCxx) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test(int a, bool b) {
   compl a;
   not b;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -881,11 +898,11 @@ void test(int a, bool b) {
     | |   `-b
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, BinaryOperator) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test(int a) {
   1 - 2;
@@ -896,7 +913,7 @@ void test(int a) {
   1 & 2;
   a ^= 3;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -969,14 +986,14 @@ void test(int a) {
     | |   `-3
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, BinaryOperatorCxx) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test(int a) {
   true || false;
@@ -984,7 +1001,7 @@ void test(int a) {
   1 bitand 2;
   a xor_eq 3;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -1033,11 +1050,11 @@ void test(int a) {
     | |   `-3
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, NestedBinaryOperator) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void test(int a, int b) {
   (1 + 2) * (4 / 2);
@@ -1046,7 +1063,7 @@ void test(int a, int b) {
   a + b * 4 + 2;
   a % 2 + b * 42;
 }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -1146,14 +1163,14 @@ void test(int a, int b) {
     | |     `-42
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UserDefinedBinaryOperator) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 struct X {
   X& operator=(const X&);
@@ -1165,7 +1182,7 @@ void test(X x, X y) {
   x + y;
   x < y;
 }
-      )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -1277,14 +1294,15 @@ void test(X x, X y) {
     | |   `-y
     | `-;
     `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, MultipleDeclaratorsGrouping) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
-      int *a, b; int *c, d;
-  )cpp",
+int *a, b;
+int *c, d;
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -1305,14 +1323,14 @@ TEST_P(SyntaxTreeTest, MultipleDeclaratorsGrouping) {
   |-SimpleDeclarator
   | `-d
   `-;
-  )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, MultipleDeclaratorsGroupingTypedef) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
-    typedef int *a, b;
-  )cpp",
+typedef int *a, b;
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -1325,17 +1343,17 @@ TEST_P(SyntaxTreeTest, MultipleDeclaratorsGroupingTypedef) {
   |-SimpleDeclarator
   | `-b
   `-;
-  )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, MultipleDeclaratorsInsideStatement) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void foo() {
-      int *a, b;
-      typedef int *ta, tb;
+  int *a, b;
+  typedef int *ta, tb;
 }
-  )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -1369,21 +1387,21 @@ void foo() {
     | |   `-tb
     | `-;
     `-}
-  )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Namespaces) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 namespace a { namespace b {} }
 namespace a::b {}
 namespace {}
 
 namespace foo = a;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-NamespaceDefinition
@@ -1413,18 +1431,18 @@ namespace foo = a;
   |-=
   |-a
   `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UsingDirective) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 namespace ns {}
 using namespace ::ns;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-NamespaceDefinition
@@ -1438,18 +1456,18 @@ using namespace ::ns;
   |-::
   |-ns
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UsingDeclaration) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 namespace ns { int a; }
 using ns::a;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-NamespaceDefinition
@@ -1468,12 +1486,12 @@ using ns::a;
   |-::
   |-a
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, FreeStandingClasses) {
   // Free-standing classes, must live inside a SimpleDeclaration.
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 struct X;
 struct X {};
@@ -1482,7 +1500,7 @@ struct Y *y1;
 struct Y {} *y2;
 
 struct {} *a1;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -1519,7 +1537,7 @@ struct {} *a1;
   | |-*
   | `-a1
   `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Templates) {
@@ -1531,12 +1549,12 @@ TEST_P(SyntaxTreeTest, Templates) {
     // tree when `-fdelayed-template-parsing` is active.
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 template <class T> struct cls {};
 template <class T> int var = 10;
 template <class T> int fun() {}
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-TemplateDeclaration
@@ -1584,21 +1602,21 @@ template <class T> int fun() {}
     `-CompoundStatement
       |-{
       `-}
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, NestedTemplates) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 template <class T>
 struct X {
   template <class U>
   U foo();
 };
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-TemplateDeclaration
@@ -1629,18 +1647,18 @@ struct X {
     |   `-;
     |-}
     `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Templates2) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 template <class T> struct X { struct Y; };
 template <class T> struct X<T>::Y {};
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-TemplateDeclaration
@@ -1678,20 +1696,20 @@ template <class T> struct X<T>::Y {};
     |-{
     |-}
     `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, TemplatesUsingUsing) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 template <class T> struct X {
   using T::foo;
   using typename T::bar;
 };
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-TemplateDeclaration
@@ -1720,14 +1738,14 @@ template <class T> struct X {
     | `-;
     |-}
     `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 template <class T> struct X {};
 template <class T> struct X<T*> {};
@@ -1800,17 +1818,17 @@ extern template struct X<float>;
     |-float
     |->
     `-;
-)txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, UsingType) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 using type = int;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-TypeAliasDeclaration
@@ -1819,30 +1837,30 @@ using type = int;
   |-=
   |-int
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, EmptyDeclaration) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 ;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-EmptyDeclaration
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, StaticAssert) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 static_assert(true, "message");
 static_assert(true);
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-StaticAssertDeclaration
@@ -1862,18 +1880,18 @@ static_assert(true);
   | `-true
   |-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ExternC) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 extern "C" int a;
 extern "C" { int b; int c; }
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-LinkageSpecificationDeclaration
@@ -1899,12 +1917,12 @@ extern "C" { int b; int c; }
   | | `-c
   | `-;
   `-}
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, NonModifiableNodes) {
   // Some nodes are non-modifiable, they are marked with 'I:'.
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 #define HALF_IF if (1+
 #define HALF_IF_2 1) {}
@@ -1940,12 +1958,12 @@ void test() {
     |   |-{
     |   `-}
     `-}
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ModifiableNodes) {
   // All nodes can be mutated.
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 #define OPEN {
 #define CLOSE }
@@ -1986,16 +2004,16 @@ void test() {
     | | `-;
     | `-}
     `-}
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ArraySubscriptsInDeclarators) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int a[10];
 int b[1][2][3];
 int c[] = {1,2,3};
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2048,17 +2066,18 @@ int c[] = {1,2,3};
   |     |-UnknownExpression
   |     | `-3
   |     `-}
-  `-;       )txt");
+  `-;
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, StaticArraySubscriptsInDeclarators) {
   if (!GetParam().isC99OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void f(int xs[static 10]);
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2078,14 +2097,15 @@ void f(int xs[static 10]);
   |   |     | `-10
   |   |     `-]
   |   `-)
-  `-;       )txt");
+  `-;
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctions) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int func1();
 int func2a(int a);
@@ -2094,7 +2114,7 @@ int func3a(int *ap);
 int func3b(int *);
 int func4a(int a, float b);
 int func4b(int, float);
-      )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2182,18 +2202,18 @@ int func4b(int, float);
   |   | `-float
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctionsCxx) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int func1(const int a, volatile int b, const volatile int c);
 int func2(int& a);
-      )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2235,17 +2255,17 @@ int func2(int& a);
   |   |   `-a
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ParametersAndQualifiersInFreeFunctionsCxx11) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int func1(int&& a);
-      )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2261,14 +2281,14 @@ int func1(int&& a);
   |   |   `-a
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ParametersAndQualifiersInMemberFunctions) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 struct Test {
   int a();
@@ -2278,7 +2298,7 @@ struct Test {
   int e() &;
   int f() &&;
 };
-      )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2341,17 +2361,17 @@ struct Test {
   | `-;
   |-}
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, TrailingReturn) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 auto foo() -> int;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2365,14 +2385,14 @@ auto foo() -> int;
   |     |-->
   |     `-int
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, DynamicExceptionSpecification) {
   if (!GetParam().supportsCXXDynamicExceptionSpecification()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 struct MyException1 {};
 struct MyException2 {};
@@ -2380,7 +2400,7 @@ int a() throw();
 int b() throw(...);
 int c() throw(MyException1);
 int d() throw(MyException1, MyException2);
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2444,18 +2464,18 @@ int d() throw(MyException1, MyException2);
   |   |-MyException2
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, NoexceptExceptionSpecification) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int a() noexcept;
 int b() noexcept(true);
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2480,17 +2500,17 @@ int b() noexcept(true);
   |   | `-true
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, DeclaratorsInParentheses) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 int (a);
 int *(b);
 int (*c)(int);
 int *(d)(int);
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2538,17 +2558,17 @@ int *(d)(int);
   |   | `-int
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ConstVolatileQualifiers) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 const int west = -1;
 int const east = 1;
 const int const universal = 0;
 const int const *const *volatile b;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2592,17 +2612,17 @@ const int const *const *volatile b;
   | |-volatile
   | `-b
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, RangesOfDeclaratorsWithTrailingReturnTypes) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 auto foo() -> auto(*)(int) -> double*;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2631,19 +2651,19 @@ auto foo() -> auto(*)(int) -> double*;
   |           `-SimpleDeclarator
   |             `-*
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, MemberPointers) {
   if (!GetParam().isCXX()) {
     return;
   }
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 struct X {};
 int X::* a;
 const int X::* b;
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 |-SimpleDeclaration
@@ -2671,14 +2691,14 @@ const int X::* b;
   | | `-*
   | `-b
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ComplexDeclarator) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void x(char a, short (*b)(int));
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2707,14 +2727,14 @@ void x(char a, short (*b)(int));
   |   |     `-)
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, ComplexDeclarator2) {
-  expectTreeDumpEqual(
+  EXPECT_TRUE(treeDumpEqual(
       R"cpp(
 void x(char a, short (*b)(int), long (**c)(long long));
-    )cpp",
+)cpp",
       R"txt(
 *: TranslationUnit
 `-SimpleDeclaration
@@ -2759,7 +2779,7 @@ void x(char a, short (*b)(int), long (**c)(long long));
   |   |     `-)
   |   `-)
   `-;
-       )txt");
+)txt"));
 }
 
 TEST_P(SyntaxTreeTest, Mutations) {