summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/libstdc++-prettyprinters/debug.cc
blob: 8ddb2e20d3b57311e3e30e4504dc7da5497fe900 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// { dg-do run }
// { dg-options "-g -O0 -std=gnu++98" }

// Copyright (C) 2011-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

#ifndef _GLIBCXX_DEBUG
# define _GLIBCXX_DEBUG
#endif

#include <string>
#include <deque>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <vector>
#include <ext/slist>

int
main()
{
  std::string tem;
  std::string str = "zardoz";
// { dg-final { note-test str "\"zardoz\"" } }

  std::bitset<10> bs;
  bs[0] = 1;
  bs[5] = 1;
  bs[7] = 1;
// { dg-final { note-test bs {std::__debug::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }

  std::deque<std::string> deq;
  deq.push_back("one");
  deq.push_back("two");
// { dg-final { note-test deq {std::__debug::deque with 2 elements = {"one", "two"}} } }

  std::deque<std::string>::iterator deqiter = deq.begin();
// { dg-final { note-test deqiter {"one"} } }

  std::list<std::string> lst;
  lst.push_back("one");
  lst.push_back("two");
// { dg-final { note-test lst {std::__debug::list = {[0] = "one", [1] = "two"}} } }

  std::list<std::string>::iterator lstiter = lst.begin();
  tem = *lstiter;
// { dg-final { note-test lstiter {"one"}} }

  std::list<std::string>::const_iterator lstciter = lst.begin();
  tem = *lstciter;
// { dg-final { note-test lstciter {"one"}} }

  std::map<std::string, int> mp;
  mp["zardoz"] = 23;
// { dg-final { note-test mp {std::__debug::map with 1 element = {["zardoz"] = 23}} } }

  std::map<std::string, int>::iterator mpiter = mp.begin();
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }

  // PR 67440
  std::set<int> intset;
  intset.insert(2);
  intset.insert(3);
  const std::set<int> const_intset = intset;
// { dg-final { note-test const_intset {std::__debug::set with 2 elements = {[0] = 2, [1] = 3}} } }

  std::set<std::string> sp;
  sp.insert("clownfish");
  sp.insert("barrel");
// { dg-final { note-test sp {std::__debug::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }

  std::set<std::string>::const_iterator spciter = sp.begin();
// { dg-final { note-test spciter {"barrel"} } }

  __gnu_cxx::slist<int> sll;
  sll.push_front(23);
  sll.push_front(47);
// { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }

  std::vector<int> v;
  v.push_back(1);
  v.push_back(2);
  std::vector<int>::iterator viter0;
// { dg-final { note-test viter0 {non-dereferenceable iterator for std::vector} } }
  std::vector<int>::iterator viter1 = v.begin();
  std::vector<int>::iterator viter2 = viter1 + 1;
  v.erase(viter1);
// { dg-final { note-test v {std::__debug::vector of length 1, capacity 2 = {2}} } }
// { dg-final { note-test viter1 {invalid iterator} } }
// { dg-final { note-test viter2 {invalid iterator} } }
  std::vector<int>::iterator viter3 = v.begin();
// { dg-final { note-test viter3 {2} } }

  __gnu_cxx::slist<int>::iterator slliter = sll.begin();
// { dg-final { note-test slliter {47} } }

  std::stringstream sstream;
  sstream << "abc";
// { dg-final { note-test sstream "\"abc\"" } }
  std::stringstream ssin("input", std::ios::in);
// { dg-final { note-test ssin "\"input\"" } }
  std::istringstream ssin2("input");
// { dg-final { note-test ssin2 "\"input\"" } }
  std::ostringstream ssout;
  ssout << "out";
// { dg-final { note-test ssout "\"out\"" } }
  std::stringstream redirected("xxx");
  static_cast<std::basic_ios<std::stringstream::char_type>&>(redirected).rdbuf(sstream.rdbuf());
// { dg-final { regexp-test redirected {std::.*stringstream redirected to .*} } }

  std::cout << "\n";
  return 0;			// Mark SPOT
}

// { dg-final { gdb-test SPOT } }