]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-xmethods / deque.cc
1 // { dg-do run }
2 // { dg-options "-g -O0" }
3
4 // Copyright (C) 2014-2020 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 #include <deque>
22
23 const int max_deque_node_size = 512;
24
25 int
26 main ()
27 {
28 std::deque<int> q0, q1, q2, q3;
29 int int_size = sizeof (int);
30
31 // The xmethod logic is exercised differently for deques of different size.
32 // Let q1 be a deque requiring only 1 node. Let q2 be a deque filling up
33 // exactly 2 nodes. Let q3 be of size which would require 1 node and part
34 // of the second node.
35 int q1_size = max_deque_node_size / int_size / 2;
36 int q2_size = max_deque_node_size / int_size * 2;
37 int q3_size = max_deque_node_size / int_size * 3 / 2;
38
39 for (int i = 0; i < q1_size; i++)
40 q1.push_back (100 + i);
41
42 for (int i = 0; i < q2_size; i++)
43 q2.push_back (200 + i);
44
45 for (int i = 0; i < q3_size; i++)
46 q3.push_back (300 + i);
47
48 // { dg-final { note-test q0.empty() true } }
49 // { dg-final { note-test q1.empty() false } }
50 // { dg-final { note-test q0.size() 0 } }
51 // { dg-final { note-test q1.size()==q1_size true } }
52 // { dg-final { note-test q2.size()==q2_size true } }
53 // { dg-final { note-test q3.size()==q3_size true } }
54 // { dg-final { note-test q1.front() 100 } }
55 // { dg-final { note-test q2.front() 200 } }
56 // { dg-final { note-test q3.front() 300 } }
57 // { dg-final { note-test q1.back()==(100+q1_size-1) true } }
58 // { dg-final { note-test q2.back()==(200+q2_size-1) true } }
59 // { dg-final { note-test q3.back()==(300+q3_size-1) true } }
60 // { dg-final { note-test q3\[0\] 300 } }
61 // { dg-final { note-test q3\[q3_size/2\]==(300+q3_size/2) true } }
62 // { dg-final { note-test q3\[q3_size-1]==(300+q3_size-1) true } }
63
64 // { dg-final { whatis-test q0.empty() bool } }
65 // { dg-final { whatis-test q0.size() std::size_t } }
66 // { dg-final { whatis-test q1.front() int } }
67 // { dg-final { whatis-test q1.back() int } }
68 // { dg-final { whatis-test q3\[0\] int } }
69
70 return 0; // Mark SPOT
71 }
72
73 // { dg-final { gdb-test SPOT {} 1 } }