[PATCH] D14686: Protect against overloaded comma in random_shuffle and improve tests
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 06:53:36 PST 2015
mclow.lists added a comment.
Nice catch. The fix in `<algorithm>` is exactly right, but I think the tests need more work.
================
Comment at: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp:35
@@ -30,1 +34,3 @@
}
+
+template <class Iter>
----------------
This is not how I would rewrite this test.
I would write a routine that took two "iterators", and called `random_shuffle`, and then checked for the desired results.
Then call it with pointers. and RA iters, etc.
for example:
template <Class Iter>
void test(Iter first, Iter last, Iter resFirst, Iter resLast);
test(nullptr, nullptr, nullptr, nullptr);
int source[] = {1, 2, 3, 4};
int res [] = {1, 2, 3, 4};
const unsigned size = sizeof(source)/sizeof(source[0]);
test(source, source + size, res, res+size);
test(random_access_iterator<int*>(source) .... );
Repository:
rL LLVM
http://reviews.llvm.org/D14686
More information about the cfe-commits
mailing list