[PATCH] Random shuffle moveable: container size
Aurelio Remonda
aurelio.remonda@tallertechnologies.com
Thu Oct 8 13:35:00 GMT 2015
This patch reduces the size of the array A (the array that contains
the values being shuffled) so the test can pass while running the
stdlibc++ testsuite.
It also make some minor changes such as:
*Deleting a useless call to fill_ascending function on test02.
*Changing N from const int to const unsigned int.
I have a company-wide copyright assignment, but I don't have commit access.
---
ChangeLog | 6 ++++++
moveable.cc | 13 ++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 91d2957..2c4e127 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-08 Aurelio Remonda <aurelio.remonda@tallertechnologies.com>
+
+ * testsuite/25_algorithms/random_shuffle/moveable.cc: Change variable
+ N from const int N = 200000 to const unsigned int N = 10000.
+ Delete useless fill_ascending function call.
+
2015-09-07 Jonathan Wakely <jwakely@redhat.com>
* include/bits/shared_ptr_base.h (__shared_ptr::operator->): Change
diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc
index e854c38..dabe9e3 100644
--- a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc
@@ -34,8 +34,8 @@ using __gnu_test::rvalstruct;
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
-const int N = 200000;
-int A[N];
+const unsigned int N = 10000;
+int A[N]; // This is made global because we don't want it on the stack
void fill_ascending()
{
@@ -56,10 +56,10 @@ test01()
// The chance that random_shuffle leaves the order as is by coincidence
// is negligible, so we expect it to be permuted
- VERIFY( !std::equal(rv, rv + N, A) );
+ VERIFY(!std::equal(rv, rv + N, A));
std::sort(con.begin(), con.end());
- VERIFY( std::equal(rv, rv + N, A) );
+ VERIFY(std::equal(rv, rv + N, A));
}
int random_generator(int)
@@ -70,14 +70,13 @@ test02()
{
bool test __attribute__((unused)) = true;
- fill_ascending();
rvalstruct rv[10] = {1,2,3,4,5,6,7,8,9,10};
int result[10] = {10,1,2,3,4,5,6,7,8,9};
Container con(rv, rv + 10);
std::random_shuffle(con.begin(), con.end(), random_generator);
// The above answer was generated by hand. It is not required by the standard,
// but is produced by the current algorithm.
- VERIFY( std::equal(rv, rv + 10, result) );
+ VERIFY(std::equal(rv, rv + 10, result));
}
int
@@ -86,4 +85,4 @@ main()
test01();
test02();
return 0;
-}
+}
\ No newline at end of file
--
1.9.1
More information about the Gcc-patches
mailing list