[llvm] r213125 - unittests: Actually test reverse iterators in Path tests
Justin Bogner
mail at justinbogner.com
Wed Jul 16 01:19:00 PDT 2014
Author: bogner
Date: Wed Jul 16 03:18:58 2014
New Revision: 213125
URL: http://llvm.org/viewvc/llvm-project?rev=213125&view=rev
Log:
unittests: Actually test reverse iterators in Path tests
This re-enables some #if 0'd code (since 2010) in the Path unittests
and makes at least a weak effort at testing sys::path's rbegin/rend.
This change was inspired by some test failures near uses of rbegin and
rend here:
http://lab.llvm.org:8011/builders/clang-x86_64-linux-vg/builds/3209
The "valgrind was whining" comment looked promising in terms of a
simpler to debug case of the same errors. However, it appears that the
valgrind complaints the comment was referring to are distinct from the
ones in the frontend, since this updated test isn't complaining for me
under valgrind.
In any case, the disabled tests weren't helping anybody.
Modified:
llvm/trunk/unittests/Support/Path.cpp
Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=213125&r1=213124&r2=213125&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Wed Jul 16 03:18:58 2014
@@ -91,6 +91,7 @@ TEST(Support, Path) {
paths.push_back("c:\\foo/");
paths.push_back("c:/foo\\bar");
+ SmallVector<StringRef, 5> ComponentStack;
for (SmallVector<StringRef, 40>::const_iterator i = paths.begin(),
e = paths.end();
i != e;
@@ -100,18 +101,17 @@ TEST(Support, Path) {
ci != ce;
++ci) {
ASSERT_FALSE(ci->empty());
+ ComponentStack.push_back(*ci);
}
-#if 0 // Valgrind is whining about this.
- outs() << " Reverse Iteration: [";
for (sys::path::reverse_iterator ci = sys::path::rbegin(*i),
ce = sys::path::rend(*i);
ci != ce;
++ci) {
- outs() << *ci << ',';
+ ASSERT_TRUE(*ci == ComponentStack.back());
+ ComponentStack.pop_back();
}
- outs() << "]\n";
-#endif
+ ASSERT_TRUE(ComponentStack.empty());
path::has_root_path(*i);
path::root_path(*i);
More information about the llvm-commits
mailing list