Skip to content

Commit e557b6a

Browse files
committed
[libc++] Remove uses of verbose_assert.h in Filesystem tests
For a modest loss of debugability in the tests, this allows more tests to run on platforms that do not have support for <iostream>.
1 parent 27a909a commit e557b6a

File tree

6 files changed

+46
-281
lines changed

6 files changed

+46
-281
lines changed

libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "test_iterators.h"
3131
#include "count_new.h"
3232
#include "filesystem_test_helper.h"
33-
#include "verbose_assert.h"
3433

3534

3635
struct AppendOperatorTestcase {
@@ -108,7 +107,7 @@ void doAppendSourceAllocTest(AppendOperatorTestcase const& TC)
108107
DisableAllocationGuard g;
109108
LHS /= RHS;
110109
}
111-
ASSERT_PRED(PathEq, LHS , E);
110+
assert(PathEq(LHS, E));
112111
}
113112
// basic_string_view
114113
{
@@ -184,8 +183,7 @@ void doAppendSourceTest(AppendOperatorTestcase const& TC)
184183
path Result(L);
185184
Str RHS(R);
186185
path& Ref = (Result /= RHS);
187-
ASSERT_EQ(Result, E)
188-
<< DISPLAY(L) << DISPLAY(R);
186+
assert(Result == E);
189187
assert(&Ref == &Result);
190188
}
191189
{
@@ -229,8 +227,7 @@ void doAppendSourceTest(AppendOperatorTestcase const& TC)
229227
path LHS(L);
230228
Ptr RHS(R);
231229
path& Ref = LHS.append(RHS, StrEnd(RHS));
232-
ASSERT_PRED(PathEq, LHS, E)
233-
<< DISPLAY(L) << DISPLAY(R);
230+
assert(PathEq(LHS, E));
234231
assert(&Ref == &LHS);
235232
}
236233
// iterators
@@ -321,8 +318,7 @@ int main(int, char**)
321318
path LHS(LHS_In);
322319
path RHS(RHS_In);
323320
path& Res = (LHS /= RHS);
324-
ASSERT_PRED(PathEq, Res, (const char*)TC.expect)
325-
<< DISPLAY(LHS_In) << DISPLAY(RHS_In);
321+
assert(PathEq(Res, (const char*)TC.expect));
326322
assert(&Res == &LHS);
327323
}
328324
doAppendSourceTest<char> (TC);

libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "test_iterators.h"
3636
#include "count_new.h"
3737
#include "filesystem_test_helper.h"
38-
#include "verbose_assert.h"
3938

4039
struct PathCompareTest {
4140
const char* LHS;
@@ -99,11 +98,10 @@ void test_compare_basic()
9998
int ret4 = normalize_ret(p1.compare(RV));
10099

101100
g.release();
102-
ASSERT_EQ(ret1, ret2);
103-
ASSERT_EQ(ret1, ret3);
104-
ASSERT_EQ(ret1, ret4);
105-
ASSERT_EQ(ret1, E)
106-
<< DISPLAY(TC.LHS) << DISPLAY(TC.RHS);
101+
assert(ret1 == ret2);
102+
assert(ret1 == ret3);
103+
assert(ret1 == ret4);
104+
assert(ret1 == E);
107105

108106
// check signatures
109107
ASSERT_NOEXCEPT(p1.compare(p2));

libcxx/test/std/input.output/filesystems/class.path/path.member/path.decompose/path.decompose.pass.cpp

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@
4444

4545

4646
#include "filesystem_include.h"
47+
#include <algorithm>
48+
#include <cassert>
49+
#include <cstddef>
50+
#include <iterator>
4751
#include <type_traits>
4852
#include <vector>
49-
#include <cassert>
5053

5154
#include "test_macros.h"
5255
#include "test_iterators.h"
5356
#include "count_new.h"
5457
#include "filesystem_test_helper.h"
55-
#include "verbose_assert.h"
5658

5759
struct ComparePathExact {
5860
bool operator()(fs::path const& LHS, std::string const& RHS) const {
@@ -120,46 +122,41 @@ void decompPathTest()
120122
using namespace fs;
121123
for (auto const & TC : PathTestCases) {
122124
fs::path p(TC.raw);
123-
ASSERT(p == TC.raw);
125+
assert(p == TC.raw);
124126

125-
ASSERT_EQ(p.root_path(), TC.root_path);
126-
ASSERT_NEQ(p.has_root_path(), TC.root_path.empty());
127+
assert(p.root_path() == TC.root_path);
128+
assert(p.has_root_path() != TC.root_path.empty());
127129

128-
ASSERT(p.root_name().native().empty())
129-
<< DISPLAY(p.root_name());
130-
ASSERT_EQ(p.root_name(),TC.root_name);
131-
ASSERT_NEQ(p.has_root_name(), TC.root_name.empty());
130+
assert(p.root_name().native().empty());
131+
assert(p.root_name() == TC.root_name);
132+
assert(p.has_root_name() != TC.root_name.empty());
132133

133-
ASSERT_EQ(p.root_directory(), TC.root_directory);
134-
ASSERT_NEQ(p.has_root_directory(), TC.root_directory.empty());
134+
assert(p.root_directory() == TC.root_directory);
135+
assert(p.has_root_directory() != TC.root_directory.empty());
135136

136-
ASSERT_EQ(p.relative_path(), TC.relative_path);
137-
ASSERT_NEQ(p.has_relative_path(), TC.relative_path.empty());
137+
assert(p.relative_path() == TC.relative_path);
138+
assert(p.has_relative_path() != TC.relative_path.empty());
138139

139-
ASSERT_EQ(p.parent_path(), TC.parent_path);
140-
ASSERT_NEQ(p.has_parent_path(), TC.parent_path.empty());
140+
assert(p.parent_path() == TC.parent_path);
141+
assert(p.has_parent_path() != TC.parent_path.empty());
141142

142-
ASSERT_EQ(p.filename(), TC.filename);
143-
ASSERT_NEQ(p.has_filename(), TC.filename.empty());
143+
assert(p.filename() == TC.filename);
144+
assert(p.has_filename() != TC.filename.empty());
144145

145-
ASSERT_EQ(p.is_absolute(), p.has_root_directory());
146-
ASSERT_NEQ(p.is_relative(), p.is_absolute());
146+
assert(p.is_absolute() == p.has_root_directory());
147+
assert(p.is_relative() != p.is_absolute());
147148
if (p.empty())
148-
ASSERT(p.is_relative());
149+
assert(p.is_relative());
149150

150-
ASSERT_COLLECTION_EQ_COMP(
151-
p.begin(), p.end(),
152-
TC.elements.begin(), TC.elements.end(),
153-
ComparePathExact()
154-
);
155-
// check backwards
151+
assert(static_cast<std::size_t>(std::distance(p.begin(), p.end())) == TC.elements.size());
152+
assert(std::equal(p.begin(), p.end(), TC.elements.begin(), ComparePathExact()));
156153

154+
// check backwards
157155
std::vector<fs::path> Parts;
158156
for (auto it = p.end(); it != p.begin(); )
159157
Parts.push_back(*--it);
160-
ASSERT_COLLECTION_EQ_COMP(Parts.begin(), Parts.end(),
161-
TC.elements.rbegin(), TC.elements.rend(),
162-
ComparePathExact());
158+
assert(static_cast<std::size_t>(std::distance(Parts.begin(), Parts.end())) == TC.elements.size());
159+
assert(std::equal(Parts.begin(), Parts.end(), TC.elements.rbegin(), ComparePathExact()));
163160
}
164161
}
165162

@@ -191,17 +188,17 @@ void decompFilenameTest()
191188
using namespace fs;
192189
for (auto const & TC : FilenameTestCases) {
193190
fs::path p(TC.raw);
194-
ASSERT_EQ(p, TC.raw);
191+
assert(p == TC.raw);
195192
ASSERT_NOEXCEPT(p.empty());
196193

197-
ASSERT_EQ(p.filename(), TC.filename);
198-
ASSERT_NEQ(p.has_filename(), TC.filename.empty());
194+
assert(p.filename() == TC.filename);
195+
assert(p.has_filename() != TC.filename.empty());
199196

200-
ASSERT_EQ(p.stem(), TC.stem);
201-
ASSERT_NEQ(p.has_stem(), TC.stem.empty());
197+
assert(p.stem() == TC.stem);
198+
assert(p.has_stem() != TC.stem.empty());
202199

203-
ASSERT_EQ(p.extension(), TC.extension);
204-
ASSERT_NEQ(p.has_extension(), TC.extension.empty());
200+
assert(p.extension() == TC.extension);
201+
assert(p.has_extension() != TC.extension.empty());
205202
}
206203
}
207204

libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/remove_filename.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "test_iterators.h"
2323
#include "count_new.h"
2424
#include "filesystem_test_helper.h"
25-
#include "verbose_assert.h"
2625

2726
struct RemoveFilenameTestcase {
2827
const char* value;
@@ -65,7 +64,7 @@ int main(int, char**)
6564
path p(p_orig);
6665
assert(p == TC.value);
6766
path& Ref = (p.remove_filename());
68-
ASSERT_EQ(p, TC.expect) << DISPLAY(p_orig);
67+
assert(p == TC.expect);
6968
assert(&Ref == &p);
7069
assert(!p.has_filename());
7170
}

libcxx/test/std/input.output/filesystems/class.path/path.member/path.modifiers/replace_filename.pass.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "test_iterators.h"
2323
#include "count_new.h"
2424
#include "filesystem_test_helper.h"
25-
#include "verbose_assert.h"
2625

2726
struct ReplaceFilenameTestcase {
2827
const char* value;
@@ -51,19 +50,17 @@ int main(int, char**)
5150
using namespace fs;
5251
for (auto const & TC : TestCases) {
5352
path p(TC.value);
54-
ASSERT_EQ(p, TC.value);
55-
path& Ref = (p.replace_filename(TC.filename));
56-
ASSERT_EQ(p, TC.expect)
57-
<< DISPLAY(TC.value)
58-
<< DISPLAY(TC.filename);
53+
assert(p == TC.value);
54+
path& Ref = p.replace_filename(TC.filename);
55+
assert(p == TC.expect);
5956
assert(&Ref == &p);
6057
// Tests Effects "as-if": remove_filename() append(filename)
6158
{
6259
path p2(TC.value);
6360
path replace(TC.filename);
6461
p2.remove_filename();
6562
p2 /= replace;
66-
ASSERT_EQ(p, p2);
63+
assert(p == p2);
6764
}
6865
}
6966

0 commit comments

Comments
 (0)