]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
097e8994 | 2 | |
83ffe9cd | 3 | // Copyright (C) 2016-2023 Free Software Foundation, Inc. |
097e8994 FD |
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 | #include <vector> | |
21 | ||
22 | #include "testsuite_hooks.h" | |
23 | ||
097e8994 FD |
24 | void test01() |
25 | { | |
26 | std::vector<std::vector<int>> vv = | |
27 | { | |
28 | { 2, 3 }, | |
29 | { 4, 5 }, | |
30 | { 0, 1 } | |
31 | }; | |
32 | ||
33 | // Make sure it doesn't reallocate during insertion. | |
34 | vv.reserve(4); | |
35 | ||
36 | vv.insert(vv.begin(), vv[0]); | |
37 | ||
38 | VERIFY( vv.size() == 4 ); | |
39 | VERIFY( vv[0].size() == 2 ); | |
40 | VERIFY( vv[0][0] == 2 ); | |
41 | VERIFY( vv[0][1] == 3 ); | |
42 | } | |
43 | ||
44 | void test02() | |
45 | { | |
46 | std::vector<std::vector<int>> vv = | |
47 | { | |
48 | { 2, 3 }, | |
49 | { 4, 5 }, | |
50 | { 0, 1 } | |
51 | }; | |
52 | ||
53 | // Make sure we will reallocate for insertion. | |
54 | VERIFY( vv.capacity() == 3 ); | |
55 | ||
56 | vv.insert(vv.begin(), vv[0]); | |
57 | ||
58 | VERIFY( vv.size() == 4 ); | |
59 | VERIFY( vv[0].size() == 2 ); | |
60 | VERIFY( vv[0][0] == 2 ); | |
61 | VERIFY( vv[0][1] == 3 ); | |
62 | } | |
63 | ||
64 | int main() | |
65 | { | |
66 | test01(); | |
67 | test02(); | |
68 | } |