Make printers use singular noun for a single element
[official-gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / debug.cc
blob833b557b4f17346b7e7add5762befc7a5315f997
1 // { dg-do run }
2 // { dg-options "-g -O0 -std=gnu++98" }
4 // Copyright (C) 2011-2016 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.
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.
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/>.
21 #define _GLIBCXX_DEBUG
23 #include <string>
24 #include <deque>
25 #include <bitset>
26 #include <iostream>
27 #include <list>
28 #include <map>
29 #include <set>
30 #include <vector>
31 #include <ext/slist>
33 int
34 main()
36 std::string tem;
37 std::string str = "zardoz";
38 // { dg-final { note-test str "\"zardoz\"" } }
40 std::bitset<10> bs;
41 bs[0] = 1;
42 bs[5] = 1;
43 bs[7] = 1;
44 // { dg-final { note-test bs {std::__debug::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
46 std::deque<std::string> deq;
47 deq.push_back("one");
48 deq.push_back("two");
49 // { dg-final { note-test deq {std::__debug::deque with 2 elements = {"one", "two"}} } }
51 std::deque<std::string>::iterator deqiter = deq.begin();
52 // { dg-final { note-test deqiter {"one"} } }
54 std::list<std::string> lst;
55 lst.push_back("one");
56 lst.push_back("two");
57 // { dg-final { note-test lst {std::__debug::list = {[0] = "one", [1] = "two"}} } }
59 std::list<std::string>::iterator lstiter = lst.begin();
60 tem = *lstiter;
61 // { dg-final { note-test lstiter {"one"}} }
63 std::list<std::string>::const_iterator lstciter = lst.begin();
64 tem = *lstciter;
65 // { dg-final { note-test lstciter {"one"}} }
67 std::map<std::string, int> mp;
68 mp["zardoz"] = 23;
69 // { dg-final { note-test mp {std::__debug::map with 1 element = {["zardoz"] = 23}} } }
71 std::map<std::string, int>::iterator mpiter = mp.begin();
72 // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
74 // PR 67440
75 std::set<int> intset;
76 intset.insert(2);
77 intset.insert(3);
78 const std::set<int> const_intset = intset;
79 // { dg-final { note-test const_intset {std::__debug::set with 2 elements = {[0] = 2, [1] = 3}} } }
81 std::set<std::string> sp;
82 sp.insert("clownfish");
83 sp.insert("barrel");
84 // { dg-final { note-test sp {std::__debug::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
86 std::set<std::string>::const_iterator spciter = sp.begin();
87 // { dg-final { note-test spciter {"barrel"} } }
89 __gnu_cxx::slist<int> sll;
90 sll.push_front(23);
91 sll.push_front(47);
92 // { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
94 std::vector<int> v;
95 v.push_back(1);
96 v.push_back(2);
97 std::vector<int>::iterator viter0;
98 // { dg-final { note-test viter0 {invalid iterator} } }
99 std::vector<int>::iterator viter1 = v.begin();
100 std::vector<int>::iterator viter2 = viter1 + 1;
101 v.erase(viter1);
102 // { dg-final { note-test v {std::__debug::vector of length 1, capacity 2 = {2}} } }
103 // { dg-final { note-test viter1 {invalid iterator} } }
104 // { dg-final { note-test viter2 {invalid iterator} } }
105 std::vector<int>::iterator viter3 = v.begin();
106 // { dg-final { note-test viter3 {2} } }
108 __gnu_cxx::slist<int>::iterator slliter = sll.begin();
109 // { dg-final { note-test slliter {47} } }
111 std::cout << "\n";
112 return 0; // Mark SPOT
115 // { dg-final { gdb-test SPOT } }