diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2020-02-22 22:40:26 +0200 |
---|---|---|
committer | Ville Voutilainen <ville.voutilainen@gmail.com> | 2020-03-31 17:07:52 +0300 |
commit | e06cde870edc7ec21736145b6857565d4b2f0e85 (patch) | |
tree | 8dfa500eadea00d24aefa075a9e10a506c19becc /libstdc++-v3/testsuite/23_containers/unordered_multiset | |
parent | 48742e02d7136e60e8e91631d76403d56e4eee09 (diff) | |
download | gcc-e06cde870edc7ec21736145b6857565d4b2f0e85.tar.gz |
Library-side tests for parenthesized aggregate init
PR c++/92878
PR c++/92947
* testsuite/20_util/allocator_traits/members/92878_92947.cc: New.
* testsuite/20_util/any/assign/92878_92947.cc: Likewise.
* testsuite/20_util/any/cons/92878_92947.cc: Likewise.
* testsuite/20_util/is_constructible/92878_92947.cc: Likewise.
* testsuite/20_util/optional/assignment/92878_92947.cc: Likewise.
* testsuite/20_util/optional/cons/92878_92947.cc: Likewise.
* testsuite/20_util/pair/cons/92878_92947.cc: Likewise.
* testsuite/20_util/shared_ptr/creation/92878_92947.cc: Likewise.
* testsuite/20_util/specialized_algorithms/construct_at/92878_92947.cc:
Likewise.
* testsuite/20_util/unique_ptr/creation/92878_92947.cc: Likewise.
* testsuite/20_util/uses_allocator/92878_92947.cc: Likewise.
* testsuite/20_util/variant/92878_92947.cc: Likewise.
* testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/forward_list/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/map/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/priority_queue/92878_92947.cc: Likewise.
* testsuite/23_containers/queue/92878_92947.cc: Likewise.
* testsuite/23_containers/set/modifiers/emplace/92878_92947.cc:
Likewise.
* testsuite/23_containers/stack/92878_92947.cc: Likewise.
* testsuite/23_containers/unordered_map/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/unordered_set/modifiers/92878_92947.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc:
Likewise.
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/unordered_multiset')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc new file mode 100644 index 00000000000..ec0c86e7222 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <unordered_set> +#include <testsuite_hooks.h> + +struct aggressive_aggregate +{ + int a; + int b; +}; + +bool operator==(const aggressive_aggregate& a, + const aggressive_aggregate& b) +{ + return a.a == b.a; +}; + +namespace std { + template<> struct hash<aggressive_aggregate> { + size_t operator()(const aggressive_aggregate& x) const { + return std::hash<int>()(x.a); + } + }; +} + +void test_emplace() +{ + std::unordered_multiset<aggressive_aggregate> x; + auto it = x.emplace(1, 2); + VERIFY(it->a == 1); + VERIFY(it->b == 2); + it = x.emplace(2); + VERIFY(it->a == 2); + VERIFY(it->b == 0); + it = x.emplace(); + VERIFY(it->a == 0); + VERIFY(it->b == 0); +} + +void test_emplace_hint() +{ + std::unordered_multiset<aggressive_aggregate> x; + auto it = x.emplace_hint(x.begin(), + 3, 2); + VERIFY(it->a == 3); + VERIFY(it->b == 2); + it = x.emplace_hint(x.begin(), + 4); + VERIFY(it->a == 4); + VERIFY(it->b == 0); + it = x.emplace_hint(x.begin()); + VERIFY(it->a == 0); + VERIFY(it->b == 0); +} + +int main() +{ + test_emplace(); + test_emplace_hint(); +} |