On 20/06/19 08:12 +0200, Stephan Bergmann wrote:
On 19/06/2019 21:54, Jonathan Wakely wrote:
On 19/06/19 21:49 +0200, Michael Weghorn wrote:
On 19/06/2019 21.37, Jonathan Wakely wrote:
+ std::vector<bool> vb;
+ vb.reserve(100);
+ vb.push_back(true);
+ vb.push_back(true);
+ vb.push_back(false);
+ vb.push_back(false);
+ vb.push_back(true);
+ vb.erase(vb.begin());
+// { dg-final { regexp-test vb {std::(__debug::)?vector of
length 4, capacity 100 = \\{true, false, false, true\\}} } }
+
This inserts 5 elements, so I'd expect that either "vector of length 5"
and an additional "true" element at the beginning need to be added for
the expected result or one of the two first 'vb.push_back(true)' needs
to be removed.
It inserts five then erases one, the test is right.
Just one thought that occurred to me while idly browsing this thread:
Wouldn't it be better in general to have non-symmetric content to test
against, to check that the printer doesn't print it in reverse?
It certainly would, good idea! It's not inconceivable that the
bit-shifting code in the printer could be backwards, or affected by
endianness.
Ideally we'd also test a vector<bool> with more than 64 elements, but
I don't have the patience to add it to the test ;-)
Tested x86_64-linux, committed to trunk.
commit 4025cc174a76ac9bdc1a77dbae88598f73ae458d
Author: Jonathan Wakely <jwak...@redhat.com>
Date: Thu Jun 20 09:59:47 2019 +0100
Improve tests for std::vector<bool> printer
The current tests wouldn't notice if the vector<bool> contents were
printed in reverse, because it would read the same forwards and
backwards. Change the content so the tests would fail if that happened.
* testsuite/libstdc++-prettyprinters/simple.cc: Use non-palindromic
vector<bool> for test.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
index 04c1ef683a6..2e7f07b649f 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc
@@ -120,11 +120,12 @@ main()
vb.reserve(100);
vb.push_back(true);
vb.push_back(true);
+ vb.push_back(true);
vb.push_back(false);
vb.push_back(false);
vb.push_back(true);
vb.erase(vb.begin());
-// { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 4, capacity 128 = \\{true, false, false, true\\}} } }
+// { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 5, capacity 128 = \\{true, true, false, false, true\\}} } }
__gnu_cxx::slist<int> sll;
sll.push_front(23);
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
index ace217cc9e8..24c871f6fba 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc
@@ -113,11 +113,12 @@ main()
vb.reserve(100);
vb.push_back(true);
vb.push_back(true);
+ vb.push_back(true);
vb.push_back(false);
vb.push_back(false);
vb.push_back(true);
vb.erase(vb.begin());
-// { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 4, capacity 128 = \\{true, false, false, true\\}} } }
+// { dg-final { regexp-test vb {std::(__debug::)?vector<bool> of length 5, capacity 128 = \\{true, true, false, false, true\\}} } }
__gnu_cxx::slist<int> sll;
sll.push_front(23);