GCC Code Coverage Report


Directory: ./
File: openvdb_ax/openvdb_ax/test/ast/TestPrinters.cc
Date: 2022-07-25 17:40:05
Exec Total Coverage
Lines: 117 122 95.9%
Functions: 4 4 100.0%
Branches: 231 488 47.3%

Line Branch Exec Source
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
4 #include <openvdb_ax/ast/AST.h>
5 #include <openvdb_ax/ast/Parse.h>
6 #include <openvdb_ax/ast/PrintTree.h>
7
8 #include <cppunit/extensions/HelperMacros.h>
9
10 #include <string>
11 #include <ostream>
12
13 using namespace openvdb::ax::ast;
14 using namespace openvdb::ax::ast::tokens;
15
16
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 class TestPrinters : public CppUnit::TestCase
17 {
18 public:
19
20
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
4 CPPUNIT_TEST_SUITE(TestPrinters);
21
5/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
6 CPPUNIT_TEST(testReprint);
22
4/8
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
4 CPPUNIT_TEST_SUITE_END();
23
24 void testReprint();
25 };
26
27 CPPUNIT_TEST_SUITE_REGISTRATION(TestPrinters);
28
29 1 void TestPrinters::testReprint()
30 {
31 // Small function providing more verbose output on failures
32
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 auto check = [](const std::string& in, const std::string& expected) {
33
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 const size_t min = std::min(in.size(), expected.size());
34
2/2
✓ Branch 0 taken 1033 times.
✓ Branch 1 taken 15 times.
1048 for (size_t i = 0; i < min; ++i) {
35
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1033 times.
1033 if (in[i] != expected[i]) {
36 std::ostringstream msg;
37 msg << "TestReprint failed at character " << i << '.'
38 << '[' << in[i] << "] vs [" << expected[i] << "]\n"
39 << "Got:\n" << in
40 << "Expected:\n" << expected;
41 CPPUNIT_FAIL(msg.str());
42 }
43 }
44
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if (in.size() != expected.size()) {
45 std::ostringstream msg;
46 msg << "TestReprint failed at end character.\n"
47 << "Got:\n" << in
48 << "Expected:\n" << expected ;
49 CPPUNIT_FAIL(msg.str());
50 }
51 15 };
52
53 2 std::ostringstream os;
54
55 // Test binary ops
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 std::string in = "a + b * c / d % e << f >> g = h & i | j ^ k && l || m;";
57
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::string expected = "(((a + (((b * c) / d) % e)) << f) >> g = ((((h & i) | (j ^ k)) && l) || m));\n";
58
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 Tree::ConstPtr tree = parse(in.c_str());
59
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
60
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
61
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
62
63 // Test binary ops paren
64
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
65
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "(a + b) * (c / d) % e << (f) >> g = (((h & i) | j) ^ k) && l || m;";
66
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "(((((a + b) * (c / d)) % e) << f) >> g = (((((h & i) | j) ^ k) && l) || m));\n";
67
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
68
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
69
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
70
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
71
72 // Test relational
73
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
74
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "a <= b; c >= d; e == f; g != h; i < j; k > l;";
75
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "(a <= b);\n(c >= d);\n(e == f);\n(g != h);\n(i < j);\n(k > l);\n";
76
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
77
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
78
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
79
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
80
81 // Test assignments
82
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
83
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "a = b; b += c; c -= d; d /= e; e *= f; f %= 1; g &= 2; h |= 3; i ^= 4; j <<= 5; k >>= 6;";
84
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "a = b;\nb += c;\nc -= d;\nd /= e;\ne *= f;\nf %= 1;\ng &= 2;\nh |= 3;\ni ^= 4;\nj <<= 5;\nk >>= 6;\n";
85
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
86
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
87
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
88
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
89
90 // Test crement
91
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
92
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "++++a; ----b; a++; b--;";
93
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "++++a;\n----b;\na++;\nb--;\n";
94
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
95
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
96
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
97
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
98
99 // Test comma
100
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
101
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "a,b,(c,d),(e,(f,(g,h,i)));";
102
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "(a, b, (c, d), (e, (f, (g, h, i))));\n";
103
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
104
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
105
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
106
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
107
108 // Test array unpack
109
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
110
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "a.x; b.y; c.z; d[0]; d[1,2]; e[(a.r, c.b), b.g];";
111
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "a[0];\nb[1];\nc[2];\nd[0];\nd[1, 2];\ne[(a[0], c[2]), b[1]];\n";
112
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
113
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
114
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
115
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
116
117 // Test array pack
118
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
119
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "a = {0,1}; b = {2,3,4}; c = {a,(b,c), d};";
120
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "a = {0, 1};\nb = {2, 3, 4};\nc = {a, (b, c), d};\n";
121
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
122
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
123
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
124
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
125
126 // Test declarations
127
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
128
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "bool a; int b,c; int32 d=0, e; int64 f; float g; double h, i=0;";
129
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "bool a;\nint32 b, c;\nint32 d = 0, e;\nint64 f;\nfloat g;\ndouble h, i = 0;\n";
130
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
131
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
132
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
133
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
134
135 // Test conditionals
136
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
137
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "if (a) b; else if (c) d; else e; if (a) if (b) { c,d; } else { e,f; }";
138
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "if (a)\n{\nb;\n}\nelse\n{\nif (c)\n{\nd;\n}\nelse\n{\ne;\n}\n}\nif (a)\n{\nif (b)\n{\n(c, d);\n}\nelse\n{\n(e, f);\n}\n}\n";
139
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
140
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
141
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
142
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
143
144 // Test keywords
145
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
146
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "return; break; continue; true; false;";
147
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "return;\nbreak;\ncontinue;\ntrue;\nfalse;\n";
148
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
149
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
150
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
151
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
152
153 // Test attributes/externals
154
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
155
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "@a; $a; v@b; v$b; f@a; f$a; i@c; i$c; s@d; s$d;";
156
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "float@a;\nfloat$a;\nvec3f@b;\nvec3f$b;\nfloat@a;\nfloat$a;\nint32@c;\nint32$c;\nstring@d;\nstring$d;\n";
157
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
158
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
159
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
160
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
161
162 // Test ternary
163
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
164
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "a ? b : c; a ? b ? c ? : d : e : f;";
165
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "a ? b : c;\na ? b ? c ?: d : e : f;\n";
166
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
167
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
168
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
169
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
170
171 // Test loops
172
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
173
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "while (a) for (int32 b, c;;) do { d; } while (e)";
174
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = "while (a)\n{\nfor (int32 b, c; true; )\n{\ndo\n{\nd;\n}\nwhile (e)\n}\n}\n";
175
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
176
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
177
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, "");
178
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
179
180 // Test loops with indents
181
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 os.str("");
182
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 in = "while (a) for (int32 b, c;;) do { d; } while (e)";
183
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 expected = " while (a)\n {\n for (int32 b, c; true; )\n {\n do\n {\n d;\n }\n while (e)\n }\n }\n";
184
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 tree = parse(in.c_str());
185
6/12
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
1 CPPUNIT_ASSERT(tree.get());
186
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 reprint(*tree, os, " ");
187
4/10
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
3 check(os.str(), ("{\n" + expected + "}\n"));
188 1 }
189
190
191