Hi! On 2021-08-17T10:57:36+0200, Richard Biener wrote: > On Tue, Aug 17, 2021 at 8:40 AM Thomas Schwinge wrote: >> On 2021-08-16T14:10:00-0600, Martin Sebor wrote: >> > On 8/16/21 6:44 AM, Thomas Schwinge wrote: >> >> [...], to document the current behavior, I propose to >> >> "Add more self-tests for 'hash_map' with Value type with non-trivial >> >> constructor/destructor", see attached. OK to push to master branch? >> >> (Also cherry-pick into release branches, eventually?) >> > Adding more tests sounds like an excellent idea. I'm not sure about >> > the idea of adding loopy selftests that iterate as many times as in >> > the patch (looks like 1234 times two?) >> >> Correct, and I agree it's a sensible concern, generally. >> >> The current 1234 times two iterations is really arbitrary (should >> document that in the test case), just so that we trigger a few hash table >> expansions. > > You could lower N_init (the default init is just 13!), > even with just 128 inserted elements you'll trigger > expansions to 31, 61 and 127 elements. > I think the test is OK but it's also reasonable to lower > the '1234' times and add a comment as to the count should > trigger hashtable expansions "a few times". Did that as follows: /* Verify basic construction and destruction of Value objects. */ { /* Configure, arbitrary. */ const size_t N_init = 0; const int N_elem = 28; ..., and: /* Verify aspects of 'hash_table::expand'. */ static void test_map_of_type_with_ctor_and_dtor_expand (bool remove_some_inline) { /* Configure, so that hash table expansion triggers a few times. */ const size_t N_init = 0; const int N_elem = 70; size_t expand_c_expected = 4; [...] if (expand) { ++expand_c; [...] ASSERT_EQ (expand_c, expand_c_expected); Given that it's all deterministic (as far as I can tell...), we may verify an exact number of hash table expansions. Pushed "Add more self-tests for 'hash_map' with Value type with non-trivial constructor/destructor" to master branch in commit e4f16e9f357a38ec702fb69a0ffab9d292a6af9b, see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955