]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / debug.cc
CommitLineData
3efe2bf7 1// { dg-do run }
5930d87a 2// { dg-options "-g -O0 -std=gnu++98" }
3efe2bf7 3
8d9254fc 4// Copyright (C) 2011-2020 Free Software Foundation, Inc.
3efe2bf7
TT
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
fe6bd21a
FD
21#ifndef _GLIBCXX_DEBUG
22# define _GLIBCXX_DEBUG
23#endif
3efe2bf7
TT
24
25#include <string>
26#include <deque>
27#include <bitset>
28#include <iostream>
29#include <list>
30#include <map>
31#include <set>
3c760f4a 32#include <vector>
3efe2bf7
TT
33#include <ext/slist>
34
35int
36main()
37{
38 std::string tem;
39 std::string str = "zardoz";
40// { dg-final { note-test str "\"zardoz\"" } }
41
42 std::bitset<10> bs;
43 bs[0] = 1;
44 bs[5] = 1;
45 bs[7] = 1;
46// { dg-final { note-test bs {std::__debug::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
47
48 std::deque<std::string> deq;
49 deq.push_back("one");
50 deq.push_back("two");
51// { dg-final { note-test deq {std::__debug::deque with 2 elements = {"one", "two"}} } }
52
53 std::deque<std::string>::iterator deqiter = deq.begin();
54// { dg-final { note-test deqiter {"one"} } }
55
56 std::list<std::string> lst;
57 lst.push_back("one");
58 lst.push_back("two");
59// { dg-final { note-test lst {std::__debug::list = {[0] = "one", [1] = "two"}} } }
60
61 std::list<std::string>::iterator lstiter = lst.begin();
62 tem = *lstiter;
63// { dg-final { note-test lstiter {"one"}} }
64
65 std::list<std::string>::const_iterator lstciter = lst.begin();
66 tem = *lstciter;
67// { dg-final { note-test lstciter {"one"}} }
68
69 std::map<std::string, int> mp;
70 mp["zardoz"] = 23;
d33c00e1 71// { dg-final { note-test mp {std::__debug::map with 1 element = {["zardoz"] = 23}} } }
3efe2bf7
TT
72
73 std::map<std::string, int>::iterator mpiter = mp.begin();
74// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
75
46d825c5 76 // PR 67440
5930d87a
JW
77 std::set<int> intset;
78 intset.insert(2);
79 intset.insert(3);
80 const std::set<int> const_intset = intset;
46d825c5
DE
81// { dg-final { note-test const_intset {std::__debug::set with 2 elements = {[0] = 2, [1] = 3}} } }
82
3efe2bf7
TT
83 std::set<std::string> sp;
84 sp.insert("clownfish");
85 sp.insert("barrel");
86// { dg-final { note-test sp {std::__debug::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
87
88 std::set<std::string>::const_iterator spciter = sp.begin();
89// { dg-final { note-test spciter {"barrel"} } }
90
91 __gnu_cxx::slist<int> sll;
92 sll.push_front(23);
93 sll.push_front(47);
94// { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
95
3c760f4a
JW
96 std::vector<int> v;
97 v.push_back(1);
98 v.push_back(2);
99 std::vector<int>::iterator viter0;
fe6bd21a 100// { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
3c760f4a
JW
101 std::vector<int>::iterator viter1 = v.begin();
102 std::vector<int>::iterator viter2 = viter1 + 1;
103 v.erase(viter1);
104// { dg-final { note-test v {std::__debug::vector of length 1, capacity 2 = {2}} } }
105// { dg-final { note-test viter1 {invalid iterator} } }
106// { dg-final { note-test viter2 {invalid iterator} } }
107 std::vector<int>::iterator viter3 = v.begin();
108// { dg-final { note-test viter3 {2} } }
109
3efe2bf7
TT
110 __gnu_cxx::slist<int>::iterator slliter = sll.begin();
111// { dg-final { note-test slliter {47} } }
112
af583c44 113 std::cout << "\n";
3efe2bf7
TT
114 return 0; // Mark SPOT
115}
116
117// { dg-final { gdb-test SPOT } }