| 1 | // 2005-01-17 Paolo Carlini <[email protected]> |
| 2 | |
| 3 | // Copyright (C) 2005-2025 Free Software Foundation, Inc. |
| 4 | // |
| 5 | // This file is part of the GNU ISO C++ Library. This library is free |
| 6 | // software; you can redistribute it and/or modify it under the |
| 7 | // terms of the GNU General Public License as published by the |
| 8 | // Free Software Foundation; either version 3, or (at your option) |
| 9 | // any later version. |
| 10 | // |
| 11 | // This library is distributed in the hope that it will be useful, |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | // GNU General Public License for more details. |
| 15 | // |
| 16 | // You should have received a copy of the GNU General Public License along |
| 17 | // with this library; see the file COPYING3. If not see |
| 18 | // <http://www.gnu.org/licenses/>. |
| 19 | // |
| 20 | |
| 21 | #include <set> |
| 22 | #include <testsuite_hooks.h> |
| 23 | |
| 24 | // A few tests for insert with hint, in the occasion of libstdc++/19422 |
| 25 | // and libstdc++/19433. |
| 26 | void test01() |
| 27 | { |
| 28 | using namespace std; |
| 29 | |
| 30 | multiset<int> ms0, ms1; |
| 31 | multiset<int>::iterator iter1; |
| 32 | |
| 33 | ms0.insert(1); |
| 34 | ms1.insert(ms1.end(), 1); |
| 35 | VERIFY( ms0 == ms1 ); |
| 36 | |
| 37 | ms0.insert(3); |
| 38 | ms1.insert(ms1.begin(), 3); |
| 39 | VERIFY( ms0 == ms1 ); |
| 40 | |
| 41 | ms0.insert(4); |
| 42 | iter1 = ms1.insert(ms1.end(), 4); |
| 43 | VERIFY( ms0 == ms1 ); |
| 44 | |
| 45 | ms0.insert(6); |
| 46 | ms1.insert(iter1, 6); |
| 47 | VERIFY( ms0 == ms1 ); |
| 48 | |
| 49 | ms0.insert(2); |
| 50 | ms1.insert(ms1.begin(), 2); |
| 51 | VERIFY( ms0 == ms1 ); |
| 52 | |
| 53 | ms0.insert(7); |
| 54 | ms1.insert(ms1.end(), 7); |
| 55 | VERIFY( ms0 == ms1 ); |
| 56 | |
| 57 | ms0.insert(5); |
| 58 | ms1.insert(ms1.find(4), 5); |
| 59 | VERIFY( ms0 == ms1 ); |
| 60 | |
| 61 | ms0.insert(0); |
| 62 | ms1.insert(ms1.end(), 0); |
| 63 | VERIFY( ms0 == ms1 ); |
| 64 | |
| 65 | ms0.insert(8); |
| 66 | ms1.insert(ms1.find(3), 8); |
| 67 | VERIFY( ms0 == ms1 ); |
| 68 | |
| 69 | ms0.insert(9); |
| 70 | ms1.insert(ms1.end(), 9); |
| 71 | VERIFY( ms0 == ms1 ); |
| 72 | |
| 73 | ms0.insert(10); |
| 74 | ms1.insert(ms1.begin(), 10); |
| 75 | VERIFY( ms0 == ms1 ); |
| 76 | } |
| 77 | |
| 78 | int main () |
| 79 | { |
| 80 | test01(); |
| 81 | return 0; |
| 82 | } |