From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Complete __gnu_debug::basic_string
Date: Thu, 1 Apr 2021 14:55:39 +0100 [thread overview]
Message-ID: <20210401135539.GP3008@redhat.com> (raw)
In-Reply-To: <0206700d-4cc1-f456-8299-6c80683636f6@gmail.com>
On 29/03/21 22:25 +0200, François Dumont wrote:
>On 25/03/21 4:29 pm, Jonathan Wakely wrote:
>>Oh, it's the same generate(sz) bug as you already found. But I've
>>found other bugs, e.g. with GLIBCXX_SEED_TEST_RNG=1908970375).
>>
>>I think we should also add a check for non-empty containers to those
>>test functions, and ensure we don't try to erase from empty
>>containers (see attached).
>>
>>
>I had a look at this patch and on my side I was more thinking about
>avoiding empty containers in the first place.
>
>What do you think ?
I did consider this and decided against it for the reasons below.
>François
>
>diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h
>index 54449d2f7bb..6940f2f765d 100644
>--- a/libstdc++-v3/testsuite/util/exception/safety.h
>+++ b/libstdc++-v3/testsuite/util/exception/safety.h
>@@ -55,14 +55,14 @@ namespace __gnu_test
>
> // Return randomly generated integer on range [0, __max_size].
> static size_type
>- generate(size_type __max_size)
>+ generate(size_type __max_size, size_type __min_size = 0)
> {
> using param_type = typename distribution_type::param_type;
>
> // Make the engine and distribution static...
> static engine_type engine = get_engine();
> static distribution_type distribution;
>- return distribution(engine, param_type{0, __max_size});
>+ return distribution(engine, param_type{__min_size, __max_size});
> }
>
> // Given an instantiating type, return a unique value.
>@@ -198,7 +198,8 @@ namespace __gnu_test
>
> // Size test container.
> const size_type max_elements = 100;
>- size_type n = generate(max_elements);
>+ const size_type min_elements = 10;
>+ size_type n = generate(max_elements, min_elements);
Why 10 though? Why not 1? Otherwise we never test the case where you
erase a single element from a container that only has a single
element.
And it would also mean we never test inserting into an empty
container, because it always starts with at least 10 elements.
So I decided that it was better to keep /most/ of the tests unchanged,
so they sometimes (depending on the RNG, which can now be made less
predictable by using a non-default seed) test with empty containers.
Only the operations that really can't work for empty containers need
to care about them. For other operations, we should keep testing the
empty case.
prev parent reply other threads:[~2021-04-01 13:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 20:55 François Dumont
2021-03-19 19:41 ` Jonathan Wakely
2021-03-20 21:32 ` François Dumont
2021-03-23 15:42 ` Jonathan Wakely
2021-03-24 21:48 ` François Dumont
2021-03-25 13:05 ` Jonathan Wakely
2021-03-25 14:48 ` Jonathan Wakely
2021-03-25 15:29 ` Jonathan Wakely
2021-03-25 17:45 ` François Dumont
2021-03-25 18:22 ` Jonathan Wakely
2021-03-29 20:25 ` François Dumont
2021-04-01 13:55 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210401135539.GP3008@redhat.com \
--to=jwakely@redhat.com \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).