1 // Copyright (C) 2010 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
21 #include <testsuite_hooks.h>
23 // Check that invalid range of pointers is detected
24 template<template<typename> class ContTraits>
28 bool test __attribute__((unused)) = true;
30 typedef ContTraits<int> Traits;
31 typedef typename Traits::cont_type cont_type;
32 typedef typename Traits::val_type val_type;
33 typedef std::vector<val_type> vector_type;
36 for (int i = 0; i != 5; ++i)
37 v.push_back(Traits::make_val(i));
38 VERIFY(v.size() == 5);
40 val_type *first = &v.front() + 1;
41 val_type *last = first + 2;
42 cont_type c1(first, last);
43 VERIFY(c1.size() == 2);
45 cont_type c2(last, first); // Expected failure
48 template<template<typename> class ContTraits>
53 debug_check1<ContTraits>();
59 // Check that invalid range of debug random iterators is detected
60 template<template<typename> class ContTraits>
64 bool test __attribute__((unused)) = true;
66 typedef ContTraits<int> Traits;
67 typedef typename Traits::cont_type cont_type;
68 typedef typename Traits::val_type val_type;
69 typedef std::vector<val_type> vector_type;
72 for (int i = 0; i != 5; ++i)
73 v.push_back(Traits::make_val(i));
74 VERIFY(v.size() == 5);
76 typename vector_type::iterator first = v.begin() + 1;
77 typename vector_type::iterator last = first + 2;
78 cont_type c1(first, last);
79 VERIFY(c1.size() == 2);
81 cont_type c2(last, first); // Expected failure
84 template<template<typename> class ContTraits>
89 debug_check2<ContTraits>();
95 // Check that invalid range of debug not random iterators is detected
96 template<template<typename> class ContTraits>
100 bool test __attribute__((unused)) = true;
102 typedef ContTraits<int> Traits;
103 typedef typename Traits::cont_type cont_type;
104 typedef typename Traits::val_type val_type;
105 typedef std::list<val_type> list_type;
107 for (int i = 0; i != 5; ++i)
108 l.push_back(Traits::make_val(i));
109 VERIFY(l.size() == 5);
111 typename list_type::iterator first = l.begin(); ++first;
112 typename list_type::iterator last = first; ++last; ++last;
113 cont_type c1(first, last);
114 VERIFY(c1.size() == 2);
116 cont_type c2(last, first); // Expected failure
119 template<template<typename> class ContTraits>
123 #ifdef _GLIBCXX_DEBUG
124 debug_check3<ContTraits>();