]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/unordered_multiset/96088.cc
aa137ec930207c610878a74d1d71c4f46eee17ac
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_multiset / 96088.cc
1 // { dg-do run { target c++17 } }
2 // { dg-require-effective-target std_allocator_new }
3
4 // Copyright (C) 2021 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 // libstdc++/96088
22
23 #include <string_view>
24 #include <string>
25 #include <unordered_set>
26
27 #include <testsuite_hooks.h>
28 #include <replacement_memory_operators.h>
29
30 static constexpr std::initializer_list<const char*> lst = {
31 "long_str_for_dynamic_allocating"
32 };
33
34 void
35 test01()
36 {
37 __gnu_test::counter::reset();
38 std::unordered_multiset<std::string,
39 std::hash<std::string_view>,
40 std::equal_to<std::string_view>> foo;
41 foo.insert(lst.begin(), lst.end());
42 VERIFY( foo.size() == 1 );
43
44 VERIFY( __gnu_test::counter::count() == 3 );
45 VERIFY( __gnu_test::counter::get()._M_increments == 3 );
46 }
47
48 void
49 test02()
50 {
51 __gnu_test::counter::reset();
52 std::unordered_multiset<std::string> foo;
53 foo.insert(lst.begin(), lst.end());
54 VERIFY( foo.size() == 1 );
55
56 VERIFY( __gnu_test::counter::count() == 3 );
57 VERIFY( __gnu_test::counter::get()._M_increments == 3 );
58 }
59
60 int
61 main()
62 {
63 test01();
64 test02();
65 return 0;
66 }