Reshuffle 23_containers testsuite.
2003-07-31 Benjamin Kosnik <bkoz@redhat.com> Reshuffle 23_containers testsuite. * 23_containers/adaptors.cc, bitset_ctor.cc,bitset_members.cc, bitset_shift.cc, deque_ctor.cc, deque_operators.cc, list_capacity.cc, list_ctor.cc, list_modifiers.cc, list_operators.cc, map_insert.cc, map_operators.cc, map_operators_neg.cc, multiset.cc, set_operators_neg.cc, vector_bool.cc, vector_capacity.cc, vector_ctor.cc, vector_element_access.cc, vector_modifiers.cc, vector_resize.cc: Split into... * 23_containers/bitset/cons/1.cc: New. * 23_containers/bitset/cons/6282.cc: New. * 23_containers/bitset/count/6124.cc: New. * 23_containers/bitset/operations/1.cc: New. * 23_containers/bitset/operations/2.cc: New. * 23_containers/bitset/test/1.cc: New. * 23_containers/bitset/to_ulong/1.cc: New. * 23_containers/deque/cons/1.cc: New. * 23_containers/deque/cons/2.cc: New. * 23_containers/deque/operators/1.cc: New. * 23_containers/list/capacity/1.cc: New. * 23_containers/list/cons/1.cc: New. * 23_containers/list/cons/2.cc: New. * 23_containers/list/cons/3.cc: New. * 23_containers/list/cons/4.cc: New. * 23_containers/list/cons/5.cc: New. * 23_containers/list/cons/6.cc: New. * 23_containers/list/cons/7.cc: New. * 23_containers/list/cons/8.cc: New. * 23_containers/list/cons/9.cc: New. * 23_containers/list/modifiers/1.cc: New. * 23_containers/list/modifiers/2.cc: New. * 23_containers/list/modifiers/3.cc: New. * 23_containers/list/operators/1.cc: New. * 23_containers/list/operators/2.cc: New. * 23_containers/list/operators/3.cc: New. * 23_containers/list/operators/4.cc: New. * 23_containers/map/insert/1.cc: New. * 23_containers/map/operators/1.cc: New. * 23_containers/map/operators/1_neg.cc: New. * 23_containers/multiset/insert/1.cc: New. * 23_containers/priority_queue/members/7161.cc: New. * 23_containers/queue/members/7157.cc: New. * 23_containers/set/operators/1_neg.cc: New. * 23_containers/stack/members/7158.cc: New. * 23_containers/vector/bool/1.cc: New. * 23_containers/vector/bool/6886.cc: New. * 23_containers/vector/capacity/1.cc: New. * 23_containers/vector/capacity/2.cc: New. * 23_containers/vector/capacity/8230.cc: New. * 23_containers/vector/cons/1.cc: New. * 23_containers/vector/cons/2.cc: New. * 23_containers/vector/cons/3.cc: New. * 23_containers/vector/cons/4.cc: New. * 23_containers/vector/cons/6513.cc: New. * 23_containers/vector/element_access/1.cc: New. * 23_containers/vector/modifiers/1.cc: New. * 23_containers/vector/modifiers/2.cc: New. * 23_containers/vector/resize/1.cc: New. From-SVN: r70011
This commit is contained in:
parent
9143c6b76b
commit
17472bb623
|
@ -1,3 +1,63 @@
|
||||||
|
2003-07-31 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
Reshuffle 23_containers testsuite.
|
||||||
|
* 23_containers/adaptors.cc, bitset_ctor.cc,bitset_members.cc,
|
||||||
|
bitset_shift.cc, deque_ctor.cc, deque_operators.cc,
|
||||||
|
list_capacity.cc, list_ctor.cc, list_modifiers.cc, list_operators.cc,
|
||||||
|
map_insert.cc, map_operators.cc, map_operators_neg.cc, multiset.cc,
|
||||||
|
set_operators_neg.cc, vector_bool.cc, vector_capacity.cc,
|
||||||
|
vector_ctor.cc, vector_element_access.cc, vector_modifiers.cc,
|
||||||
|
vector_resize.cc: Split into...
|
||||||
|
* 23_containers/bitset/cons/1.cc: New.
|
||||||
|
* 23_containers/bitset/cons/6282.cc: New.
|
||||||
|
* 23_containers/bitset/count/6124.cc: New.
|
||||||
|
* 23_containers/bitset/operations/1.cc: New.
|
||||||
|
* 23_containers/bitset/operations/2.cc: New.
|
||||||
|
* 23_containers/bitset/test/1.cc: New.
|
||||||
|
* 23_containers/bitset/to_ulong/1.cc: New.
|
||||||
|
* 23_containers/deque/cons/1.cc: New.
|
||||||
|
* 23_containers/deque/cons/2.cc: New.
|
||||||
|
* 23_containers/deque/operators/1.cc: New.
|
||||||
|
* 23_containers/list/capacity/1.cc: New.
|
||||||
|
* 23_containers/list/cons/1.cc: New.
|
||||||
|
* 23_containers/list/cons/2.cc: New.
|
||||||
|
* 23_containers/list/cons/3.cc: New.
|
||||||
|
* 23_containers/list/cons/4.cc: New.
|
||||||
|
* 23_containers/list/cons/5.cc: New.
|
||||||
|
* 23_containers/list/cons/6.cc: New.
|
||||||
|
* 23_containers/list/cons/7.cc: New.
|
||||||
|
* 23_containers/list/cons/8.cc: New.
|
||||||
|
* 23_containers/list/cons/9.cc: New.
|
||||||
|
* 23_containers/list/modifiers/1.cc: New.
|
||||||
|
* 23_containers/list/modifiers/2.cc: New.
|
||||||
|
* 23_containers/list/modifiers/3.cc: New.
|
||||||
|
* 23_containers/list/operators/1.cc: New.
|
||||||
|
* 23_containers/list/operators/2.cc: New.
|
||||||
|
* 23_containers/list/operators/3.cc: New.
|
||||||
|
* 23_containers/list/operators/4.cc: New.
|
||||||
|
* 23_containers/map/insert/1.cc: New.
|
||||||
|
* 23_containers/map/operators/1.cc: New.
|
||||||
|
* 23_containers/map/operators/1_neg.cc: New.
|
||||||
|
* 23_containers/multiset/insert/1.cc: New.
|
||||||
|
* 23_containers/priority_queue/members/7161.cc: New.
|
||||||
|
* 23_containers/queue/members/7157.cc: New.
|
||||||
|
* 23_containers/set/operators/1_neg.cc: New.
|
||||||
|
* 23_containers/stack/members/7158.cc: New.
|
||||||
|
* 23_containers/vector/bool/1.cc: New.
|
||||||
|
* 23_containers/vector/bool/6886.cc: New.
|
||||||
|
* 23_containers/vector/capacity/1.cc: New.
|
||||||
|
* 23_containers/vector/capacity/2.cc: New.
|
||||||
|
* 23_containers/vector/capacity/8230.cc: New.
|
||||||
|
* 23_containers/vector/cons/1.cc: New.
|
||||||
|
* 23_containers/vector/cons/2.cc: New.
|
||||||
|
* 23_containers/vector/cons/3.cc: New.
|
||||||
|
* 23_containers/vector/cons/4.cc: New.
|
||||||
|
* 23_containers/vector/cons/6513.cc: New.
|
||||||
|
* 23_containers/vector/element_access/1.cc: New.
|
||||||
|
* 23_containers/vector/modifiers/1.cc: New.
|
||||||
|
* 23_containers/vector/modifiers/2.cc: New.
|
||||||
|
* 23_containers/vector/resize/1.cc: New.
|
||||||
|
|
||||||
2003-07-31 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
2003-07-31 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
|
||||||
|
|
||||||
* testsuite/thread/pthread1.cc: Add alpha*-*-osf* to dg-do run,
|
* testsuite/thread/pthread1.cc: Add alpha*-*-osf* to dg-do run,
|
||||||
|
|
|
@ -76,42 +76,8 @@ bool test01(void)
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
// boundary condition: a zero-sized set
|
|
||||||
// libstdc++/6282
|
|
||||||
bool test02(void)
|
|
||||||
{
|
|
||||||
using std::char_traits; using std::allocator;
|
|
||||||
bool test = true;
|
|
||||||
|
|
||||||
std::bitset<0> z1;
|
|
||||||
VERIFY( z1.any() == false );
|
|
||||||
|
|
||||||
std::bitset<0> z2(12345);
|
|
||||||
VERIFY( z2.any() == false );
|
|
||||||
|
|
||||||
std::bitset<0> z3(std::string("10101010101"));
|
|
||||||
VERIFY( z3.any() == false );
|
|
||||||
|
|
||||||
try {
|
|
||||||
z1.set(0);
|
|
||||||
VERIFY( false );
|
|
||||||
}
|
|
||||||
catch(std::out_of_range& fail) {
|
|
||||||
VERIFY( true );
|
|
||||||
}
|
|
||||||
catch(...) {
|
|
||||||
VERIFY( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
VERIFY( z1.to_ulong() == 0 );
|
|
||||||
VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() ));
|
|
||||||
return test;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
// 1999-06-08 bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999, 2000, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.3.5.1 bitset constructors
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <bitset>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// boundary condition: a zero-sized set
|
||||||
|
// libstdc++/6282
|
||||||
|
bool test02(void)
|
||||||
|
{
|
||||||
|
using std::char_traits; using std::allocator;
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
std::bitset<0> z1;
|
||||||
|
VERIFY( z1.any() == false );
|
||||||
|
|
||||||
|
std::bitset<0> z2(12345);
|
||||||
|
VERIFY( z2.any() == false );
|
||||||
|
|
||||||
|
std::bitset<0> z3(std::string("10101010101"));
|
||||||
|
VERIFY( z3.any() == false );
|
||||||
|
|
||||||
|
try {
|
||||||
|
z1.set(0);
|
||||||
|
VERIFY( false );
|
||||||
|
}
|
||||||
|
catch(std::out_of_range& fail) {
|
||||||
|
VERIFY( true );
|
||||||
|
}
|
||||||
|
catch(...) {
|
||||||
|
VERIFY( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
VERIFY( z1.to_ulong() == 0 );
|
||||||
|
VERIFY( (z1.to_string<char,char_traits<char>,allocator<char> >().empty() ));
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
// 2001-06-03 pme
|
||||||
|
|
||||||
|
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.3.5.2 bitset members
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// libstdc++/6124
|
||||||
|
void test02()
|
||||||
|
{
|
||||||
|
std::bitset<1> bs;
|
||||||
|
bs.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -21,7 +21,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
static char original_bits[1024];
|
static char original_bits[1024];
|
||||||
|
@ -102,21 +101,9 @@ test01() {
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
test02()
|
|
||||||
{
|
|
||||||
bool test = true;
|
|
||||||
|
|
||||||
std::bitset<66> b;
|
|
||||||
b <<= 400;
|
|
||||||
VERIFY( b.count() == 0 );
|
|
||||||
return test;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main() {
|
main()
|
||||||
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
// 2000-01-15 Anders Widell <awl@hem.passagen.se>
|
||||||
|
|
||||||
|
// Copyright (C) 2000, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <set>
|
||||||
|
#include <bitset>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool
|
||||||
|
test02()
|
||||||
|
{
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
std::bitset<66> b;
|
||||||
|
b <<= 400;
|
||||||
|
VERIFY( b.count() == 0 );
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -46,34 +46,8 @@ test01(void)
|
||||||
VERIFY( test );
|
VERIFY( test );
|
||||||
}
|
}
|
||||||
|
|
||||||
// libstdc++/6124
|
|
||||||
void test02()
|
|
||||||
{
|
|
||||||
std::bitset<1> bs;
|
|
||||||
bs.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
void test03()
|
|
||||||
{
|
|
||||||
bool test = true;
|
|
||||||
std::bitset<5> b;
|
|
||||||
std::stringstream ss ("101");
|
|
||||||
|
|
||||||
ss.exceptions(std::ios_base::eofbit);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ss >> b;
|
|
||||||
}
|
|
||||||
catch (std::exception&) {}
|
|
||||||
|
|
||||||
VERIFY( b.to_ulong() == 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
test02();
|
|
||||||
test03();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
// 2001-06-03 pme
|
||||||
|
|
||||||
|
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.3.5.2 bitset members
|
||||||
|
|
||||||
|
#include <bitset>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void test03()
|
||||||
|
{
|
||||||
|
bool test = true;
|
||||||
|
std::bitset<5> b;
|
||||||
|
std::stringstream ss("101");
|
||||||
|
ss.exceptions(std::ios_base::eofbit);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ss >> b;
|
||||||
|
}
|
||||||
|
catch (std::exception&) { }
|
||||||
|
|
||||||
|
VERIFY( b.to_ulong() == 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test03();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
// 2001-12-27 pme
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.1.1 deque constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
#include <iterator>
|
||||||
|
#include <sstream>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
typedef std::deque<__gnu_test::counter> gdeque;
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// see http://gcc.gnu.org/ml/libstdc++/2001-11/msg00139.html
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
assert_count (0);
|
||||||
|
{
|
||||||
|
gdeque d(10);
|
||||||
|
assert_count (10);
|
||||||
|
}
|
||||||
|
assert_count (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// specific bug fix checks
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -38,19 +38,6 @@ typedef std::deque<counter> gdeque;
|
||||||
|
|
||||||
bool test = true;
|
bool test = true;
|
||||||
|
|
||||||
// see http://gcc.gnu.org/ml/libstdc++/2001-11/msg00139.html
|
|
||||||
void
|
|
||||||
test01()
|
|
||||||
{
|
|
||||||
assert_count (0);
|
|
||||||
{
|
|
||||||
gdeque d(10);
|
|
||||||
assert_count (10);
|
|
||||||
}
|
|
||||||
assert_count (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 23.2.1 required types
|
// 23.2.1 required types
|
||||||
//
|
//
|
||||||
// A missing required type will cause a compile failure.
|
// A missing required type will cause a compile failure.
|
||||||
|
@ -531,9 +518,5 @@ int main()
|
||||||
fillAssignmentCheck2();
|
fillAssignmentCheck2();
|
||||||
rangeAssignmentCheck();
|
rangeAssignmentCheck();
|
||||||
rangeAssignmentCheckWithException();
|
rangeAssignmentCheckWithException();
|
||||||
|
return 0;
|
||||||
// specific bug fix checks
|
|
||||||
test01();
|
|
||||||
|
|
||||||
return !test;
|
|
||||||
}
|
}
|
|
@ -62,9 +62,8 @@ test01()
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[])
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
test01();
|
test01();
|
||||||
|
return 0;
|
||||||
return !test;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// vi:set sw=2 ts=2:
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,79 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// A nontrivial type.
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
// Another nontrivial type
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
// A nontrivial type convertible from an int
|
||||||
|
struct C {
|
||||||
|
C(int i) : i_(i) { }
|
||||||
|
bool operator==(const C& rhs) { return i_ == rhs.i_; }
|
||||||
|
int i_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default constructor, basic properties
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2.1 explicit list(const a& = Allocator())
|
||||||
|
// 23.1 (7) iterator behaviour of empty containers
|
||||||
|
// 23.2.2 iterator begin()
|
||||||
|
// 23.2.2 iterator end()
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
// 23.2.2 existence of required typedefs
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::list< A<B> > list0101;
|
||||||
|
VERIFY(list0101.begin() == list0101.end());
|
||||||
|
VERIFY(list0101.size() == 0);
|
||||||
|
|
||||||
|
// check type definitions -- will fail compile if missing
|
||||||
|
typedef std::list< A<B> >::reference reference;
|
||||||
|
typedef std::list< A<B> >::const_reference const_reference;
|
||||||
|
typedef std::list< A<B> >::iterator iterator;
|
||||||
|
typedef std::list< A<B> >::const_iterator const_iterator;
|
||||||
|
typedef std::list< A<B> >::size_type size_type;
|
||||||
|
typedef std::list< A<B> >::difference_type difference_type;
|
||||||
|
typedef std::list< A<B> >::value_type value_type;
|
||||||
|
typedef std::list< A<B> >::allocator_type allocator_type;
|
||||||
|
typedef std::list< A<B> >::pointer pointer;
|
||||||
|
typedef std::list< A<B> >::const_pointer const_pointer;
|
||||||
|
typedef std::list< A<B> >::reverse_iterator reverse_iterator;
|
||||||
|
typedef std::list< A<B> >::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
// allocator checks?
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,83 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// A nontrivial type.
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
// Another nontrivial type
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
// A nontrivial type convertible from an int
|
||||||
|
struct C {
|
||||||
|
C(int i) : i_(i) { }
|
||||||
|
bool operator==(const C& rhs) { return i_ == rhs.i_; }
|
||||||
|
int i_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fill constructor
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator())
|
||||||
|
// 23.2.2 const_iterator begin() const
|
||||||
|
// 23.2.2 const_iterator end() const
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test02()
|
||||||
|
{
|
||||||
|
const int LIST_SIZE = 5;
|
||||||
|
const int INIT_VALUE = 7;
|
||||||
|
int count;
|
||||||
|
std::list<int>::const_iterator i;
|
||||||
|
|
||||||
|
// nontrivial value_type
|
||||||
|
std::list< A<B> > list0201(LIST_SIZE);
|
||||||
|
|
||||||
|
// default value
|
||||||
|
std::list<int> list0202(LIST_SIZE);
|
||||||
|
for (i = list0202.begin(), count = 0;
|
||||||
|
i != list0202.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == 0);
|
||||||
|
VERIFY(count == LIST_SIZE);
|
||||||
|
VERIFY(list0202.size() == LIST_SIZE);
|
||||||
|
|
||||||
|
// explicit value
|
||||||
|
std::list<int> list0203(LIST_SIZE, INIT_VALUE);
|
||||||
|
for (i = list0203.begin(), count = 0;
|
||||||
|
i != list0203.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == INIT_VALUE);
|
||||||
|
VERIFY(count == LIST_SIZE);
|
||||||
|
VERIFY(list0203.size() == LIST_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// A nontrivial type.
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
// Another nontrivial type
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
// A nontrivial type convertible from an int
|
||||||
|
struct C {
|
||||||
|
C(int i) : i_(i) { }
|
||||||
|
bool operator==(const C& rhs) { return i_ == rhs.i_; }
|
||||||
|
int i_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fill constructor disguised as a range constructor
|
||||||
|
void
|
||||||
|
test02D()
|
||||||
|
{
|
||||||
|
const int LIST_SIZE = 5;
|
||||||
|
const int INIT_VALUE = 7;
|
||||||
|
int count = 0;
|
||||||
|
std::list<C> list0204(LIST_SIZE, INIT_VALUE);
|
||||||
|
std::list<C>::iterator i = list0204.begin();
|
||||||
|
for (; i != list0204.end(); ++i, ++count)
|
||||||
|
VERIFY(*i == INIT_VALUE);
|
||||||
|
VERIFY(count == LIST_SIZE);
|
||||||
|
VERIFY(list0204.size() == LIST_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02D();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,66 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// Range constructor
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2.1 template list(InputIterator f, InputIterator l, const Allocator& a = Allocator())
|
||||||
|
// 23.2.2 const_iterator begin() const
|
||||||
|
// 23.2.2 const_iterator end() const
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test03()
|
||||||
|
{
|
||||||
|
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
int count;
|
||||||
|
std::list<int>::const_iterator i;
|
||||||
|
|
||||||
|
// construct from a dissimilar range
|
||||||
|
std::list<int> list0301(A, A + N);
|
||||||
|
for (i = list0301.begin(), count = 0;
|
||||||
|
i != list0301.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == A[count]);
|
||||||
|
VERIFY(count == N);
|
||||||
|
VERIFY(list0301.size() == N);
|
||||||
|
|
||||||
|
// construct from a similar range
|
||||||
|
std::list<int> list0302(list0301.begin(), list0301.end());
|
||||||
|
for (i = list0302.begin(), count = 0;
|
||||||
|
i != list0302.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == A[count]);
|
||||||
|
VERIFY(count == N);
|
||||||
|
VERIFY(list0302.size() == N);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test03();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// Copy constructor
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2.1 list(const list& x)
|
||||||
|
// 23.2.2 reverse_iterator rbegin()
|
||||||
|
// 23.2.2 reverse_iterator rend()
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test04()
|
||||||
|
{
|
||||||
|
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
int count;
|
||||||
|
std::list<int>::reverse_iterator i;
|
||||||
|
std::list<int> list0401(A, A + N);
|
||||||
|
|
||||||
|
std::list<int> list0402(list0401);
|
||||||
|
for (i = list0401.rbegin(), count = N - 1;
|
||||||
|
i != list0401.rend();
|
||||||
|
++i, --count)
|
||||||
|
VERIFY(*i == A[count]);
|
||||||
|
VERIFY(count == -1);
|
||||||
|
VERIFY(list0401.size() == N);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test04();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,70 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// Range assign
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2.1 void assign(InputIterator f, InputIterator l)
|
||||||
|
// 23.2.2 const_iterator begin() const
|
||||||
|
// 23.2.2 const_iterator end() const
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test05()
|
||||||
|
{
|
||||||
|
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||||
|
const int B[] = {101, 102, 103, 104, 105};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
const int M = sizeof(B) / sizeof(int);
|
||||||
|
int count;
|
||||||
|
std::list<int>::const_iterator i;
|
||||||
|
|
||||||
|
std::list<int> list0501;
|
||||||
|
|
||||||
|
// make it bigger
|
||||||
|
list0501.assign(A, A + N);
|
||||||
|
for (i = list0501.begin(), count = 0;
|
||||||
|
i != list0501.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == A[count]);
|
||||||
|
VERIFY(count == N);
|
||||||
|
VERIFY(list0501.size() == N);
|
||||||
|
|
||||||
|
// make it smaller
|
||||||
|
list0501.assign(B, B + M);
|
||||||
|
for (i = list0501.begin(), count = 0;
|
||||||
|
i != list0501.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == B[count]);
|
||||||
|
VERIFY(count == M);
|
||||||
|
VERIFY(list0501.size() == M);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test05();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// Fill assign
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2.1 void assign(size_type n, const T& v)
|
||||||
|
// 23.2.2 const_iterator begin() const
|
||||||
|
// 23.2.2 const_iterator end() const
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test06()
|
||||||
|
{
|
||||||
|
const int BIG_LIST_SIZE = 11;
|
||||||
|
const int BIG_INIT_VALUE = 7;
|
||||||
|
const int SMALL_LIST_SIZE = 5;
|
||||||
|
const int SMALL_INIT_VALUE = 17;
|
||||||
|
int count;
|
||||||
|
std::list<int>::const_iterator i;
|
||||||
|
|
||||||
|
std::list<int> list0601;
|
||||||
|
VERIFY(list0601.size() == 0);
|
||||||
|
|
||||||
|
// make it bigger
|
||||||
|
list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE);
|
||||||
|
for (i = list0601.begin(), count = 0;
|
||||||
|
i != list0601.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == BIG_INIT_VALUE);
|
||||||
|
VERIFY(count == BIG_LIST_SIZE);
|
||||||
|
VERIFY(list0601.size() == BIG_LIST_SIZE);
|
||||||
|
|
||||||
|
// make it shrink
|
||||||
|
list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE);
|
||||||
|
for (i = list0601.begin(), count = 0;
|
||||||
|
i != list0601.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == SMALL_INIT_VALUE);
|
||||||
|
VERIFY(count == SMALL_LIST_SIZE);
|
||||||
|
VERIFY(list0601.size() == SMALL_LIST_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test06();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
|
||||||
|
// A nontrivial type.
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
// Another nontrivial type
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
// A nontrivial type convertible from an int
|
||||||
|
struct C {
|
||||||
|
C(int i) : i_(i) { }
|
||||||
|
bool operator==(const C& rhs) { return i_ == rhs.i_; }
|
||||||
|
int i_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fill Assignment disguised as a Range Assignment
|
||||||
|
void
|
||||||
|
test06D()
|
||||||
|
{
|
||||||
|
const int LIST_SIZE = 5;
|
||||||
|
const int INIT_VALUE = 7;
|
||||||
|
int count = 0;
|
||||||
|
std::list<C> list0604;
|
||||||
|
VERIFY(list0604.size() == 0);
|
||||||
|
|
||||||
|
list0604.assign(LIST_SIZE, INIT_VALUE);
|
||||||
|
std::list<C>::iterator i = list0604.begin();
|
||||||
|
for (; i != list0604.end(); ++i, ++count)
|
||||||
|
VERIFY(*i == INIT_VALUE);
|
||||||
|
VERIFY(count == LIST_SIZE);
|
||||||
|
VERIFY(list0604.size() == LIST_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test06D();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.1 list constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// Assignment operator
|
||||||
|
//
|
||||||
|
// This test verifies the following.
|
||||||
|
// 23.2.2 operator=(const list& x)
|
||||||
|
// 23.2.2 iterator begin()
|
||||||
|
// 23.2.2 iterator end()
|
||||||
|
// 23.2.2 size_type size() const
|
||||||
|
// 23.2.2 bool operator==(const list& x, const list& y)
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test07()
|
||||||
|
{
|
||||||
|
const int A[] = {701, 702, 703, 704, 705};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
int count;
|
||||||
|
std::list<int>::iterator i;
|
||||||
|
|
||||||
|
std::list<int> list0701(A, A + N);
|
||||||
|
VERIFY(list0701.size() == N);
|
||||||
|
|
||||||
|
std::list<int> list0702;
|
||||||
|
VERIFY(list0702.size() == 0);
|
||||||
|
|
||||||
|
list0702 = list0701;
|
||||||
|
VERIFY(list0702.size() == N);
|
||||||
|
for (i = list0702.begin(), count = 0;
|
||||||
|
i != list0702.end();
|
||||||
|
++i, ++count)
|
||||||
|
VERIFY(*i == A[count]);
|
||||||
|
VERIFY(count == N);
|
||||||
|
VERIFY(list0702 == list0701);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test07();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,120 @@
|
||||||
|
// Copyright (C) 2001, 2003 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.3 list modifiers [lib.list.modifiers]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
typedef __gnu_test::copy_tracker T;
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// range and fill insert/erase + clear
|
||||||
|
// missing: o fill insert disguised as a range insert in all its variants
|
||||||
|
// o exception effects
|
||||||
|
void
|
||||||
|
test03()
|
||||||
|
{
|
||||||
|
std::list<T> list0301;
|
||||||
|
T::reset();
|
||||||
|
|
||||||
|
// fill insert at beginning of list / empty list
|
||||||
|
list0301.insert(list0301.begin(), 3, T(11)); // should be [11 11 11]
|
||||||
|
VERIFY(list0301.size() == 3);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
|
||||||
|
// save iterators to verify post-insert validity
|
||||||
|
std::list<T>::iterator b = list0301.begin();
|
||||||
|
std::list<T>::iterator m = list0301.end(); --m;
|
||||||
|
std::list<T>::iterator e = list0301.end();
|
||||||
|
|
||||||
|
// fill insert at end of list
|
||||||
|
T::reset();
|
||||||
|
list0301.insert(list0301.end(), 3, T(13)); // should be [11 11 11 13 13 13]
|
||||||
|
VERIFY(list0301.size() == 6);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
VERIFY(b == list0301.begin() && b->id() == 11);
|
||||||
|
VERIFY(e == list0301.end());
|
||||||
|
VERIFY(m->id() == 11);
|
||||||
|
|
||||||
|
// fill insert in the middle of list
|
||||||
|
++m;
|
||||||
|
T::reset();
|
||||||
|
list0301.insert(m, 3, T(12)); // should be [11 11 11 12 12 12 13 13 13]
|
||||||
|
VERIFY(list0301.size() == 9);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
VERIFY(b == list0301.begin() && b->id() == 11);
|
||||||
|
VERIFY(e == list0301.end());
|
||||||
|
VERIFY(m->id() == 13);
|
||||||
|
|
||||||
|
// single erase
|
||||||
|
T::reset();
|
||||||
|
m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
|
||||||
|
VERIFY(list0301.size() == 8);
|
||||||
|
VERIFY(T::dtorCount() == 1);
|
||||||
|
VERIFY(b == list0301.begin() && b->id() == 11);
|
||||||
|
VERIFY(e == list0301.end());
|
||||||
|
VERIFY(m->id() == 13);
|
||||||
|
|
||||||
|
// range erase
|
||||||
|
T::reset();
|
||||||
|
m = list0301.erase(list0301.begin(), m); // should be [13 13]
|
||||||
|
VERIFY(list0301.size() == 2);
|
||||||
|
VERIFY(T::dtorCount() == 6);
|
||||||
|
VERIFY(m->id() == 13);
|
||||||
|
|
||||||
|
// range fill at beginning
|
||||||
|
const int A[] = {321, 322, 333};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
T::reset();
|
||||||
|
b = list0301.begin();
|
||||||
|
list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
|
||||||
|
VERIFY(list0301.size() == 5);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
VERIFY(m->id() == 13);
|
||||||
|
|
||||||
|
// range fill at end
|
||||||
|
T::reset();
|
||||||
|
list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
|
||||||
|
VERIFY(list0301.size() == 8);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
VERIFY(e == list0301.end());
|
||||||
|
VERIFY(m->id() == 13);
|
||||||
|
|
||||||
|
// range fill in middle
|
||||||
|
T::reset();
|
||||||
|
list0301.insert(m, A, A + N);
|
||||||
|
VERIFY(list0301.size() == 11);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
VERIFY(e == list0301.end());
|
||||||
|
VERIFY(m->id() == 13);
|
||||||
|
|
||||||
|
T::reset();
|
||||||
|
list0301.clear();
|
||||||
|
VERIFY(list0301.size() == 0);
|
||||||
|
VERIFY(T::dtorCount() == 11);
|
||||||
|
VERIFY(e == list0301.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test03();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,92 @@
|
||||||
|
// Copyright (C) 2001, 2003 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.3 list modifiers [lib.list.modifiers]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
typedef __gnu_test::copy_tracker T;
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// general single insert/erase + swap
|
||||||
|
void
|
||||||
|
test02()
|
||||||
|
{
|
||||||
|
std::list<T> list0201;
|
||||||
|
T::reset();
|
||||||
|
|
||||||
|
list0201.insert(list0201.begin(), T(1)); // list should be [1]
|
||||||
|
VERIFY(list0201.size() == 1);
|
||||||
|
VERIFY(T::copyCount() == 1);
|
||||||
|
|
||||||
|
list0201.insert(list0201.end(), T(2)); // list should be [1 2]
|
||||||
|
VERIFY(list0201.size() == 2);
|
||||||
|
VERIFY(T::copyCount() == 2);
|
||||||
|
|
||||||
|
std::list<T>::iterator i = list0201.begin();
|
||||||
|
std::list<T>::const_iterator j = i;
|
||||||
|
VERIFY(i->id() == 1); ++i;
|
||||||
|
VERIFY(i->id() == 2);
|
||||||
|
|
||||||
|
list0201.insert(i, T(3)); // list should be [1 3 2]
|
||||||
|
VERIFY(list0201.size() == 3);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
|
||||||
|
std::list<T>::const_iterator k = i;
|
||||||
|
VERIFY(i->id() == 2); --i;
|
||||||
|
VERIFY(i->id() == 3); --i;
|
||||||
|
VERIFY(i->id() == 1);
|
||||||
|
VERIFY(j->id() == 1);
|
||||||
|
|
||||||
|
++i; // will point to '3'
|
||||||
|
T::reset();
|
||||||
|
list0201.erase(i); // should be [1 2]
|
||||||
|
VERIFY(list0201.size() == 2);
|
||||||
|
VERIFY(T::dtorCount() == 1);
|
||||||
|
VERIFY(k->id() == 2);
|
||||||
|
VERIFY(j->id() == 1);
|
||||||
|
|
||||||
|
std::list<T> list0202;
|
||||||
|
T::reset();
|
||||||
|
VERIFY(list0202.size() == 0);
|
||||||
|
VERIFY(T::copyCount() == 0);
|
||||||
|
VERIFY(T::dtorCount() == 0);
|
||||||
|
|
||||||
|
// member swap
|
||||||
|
list0202.swap(list0201);
|
||||||
|
VERIFY(list0201.size() == 0);
|
||||||
|
VERIFY(list0202.size() == 2);
|
||||||
|
VERIFY(T::copyCount() == 0);
|
||||||
|
VERIFY(T::dtorCount() == 0);
|
||||||
|
|
||||||
|
// specialized swap
|
||||||
|
swap(list0201, list0202);
|
||||||
|
VERIFY(list0201.size() == 2);
|
||||||
|
VERIFY(list0202.size() == 0);
|
||||||
|
VERIFY(T::copyCount() == 0);
|
||||||
|
VERIFY(T::dtorCount() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,124 @@
|
||||||
|
// Copyright (C) 2001, 2003 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.3 list modifiers [lib.list.modifiers]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
typedef __gnu_test::copy_tracker T;
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
|
||||||
|
// This test verifies the following.
|
||||||
|
//
|
||||||
|
// 23.2.2.3 void push_front(const T& x)
|
||||||
|
// 23.2.2.3 void push_back(const T& x)
|
||||||
|
// 23.2.2.3 (1) iterator and reference non-invalidation
|
||||||
|
// 23.2.2.3 (1) exception effects
|
||||||
|
// 23.2.2.3 (2) complexity requirements
|
||||||
|
//
|
||||||
|
// 23.2.2.3 void pop_front()
|
||||||
|
// 23.2.2.3 void pop_back()
|
||||||
|
// 23.2.2.3 (3) iterator and reference non-invalidation
|
||||||
|
// 23.2.2.3 (5) complexity requirements
|
||||||
|
//
|
||||||
|
// 23.2.2 const_iterator begin() const
|
||||||
|
// 23.2.2 iterator end()
|
||||||
|
// 23.2.2 const_reverse_iterator rbegin() const
|
||||||
|
// 23.2.2 _reference front()
|
||||||
|
// 23.2.2 const_reference front() const
|
||||||
|
// 23.2.2 reference back()
|
||||||
|
// 23.2.2 const_reference back() const
|
||||||
|
//
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::list<T> list0101;
|
||||||
|
std::list<T>::const_iterator i;
|
||||||
|
std::list<T>::const_reverse_iterator j;
|
||||||
|
std::list<T>::iterator k;
|
||||||
|
T::reset();
|
||||||
|
|
||||||
|
list0101.push_back(T(1)); // list should be [1]
|
||||||
|
VERIFY(list0101.size() == 1);
|
||||||
|
VERIFY(T::copyCount() == 1);
|
||||||
|
|
||||||
|
k = list0101.end();
|
||||||
|
--k;
|
||||||
|
VERIFY(k->id() == 1);
|
||||||
|
VERIFY(k->id() == list0101.front().id());
|
||||||
|
VERIFY(k->id() == list0101.back().id());
|
||||||
|
|
||||||
|
list0101.push_front(T(2)); // list should be [2 1]
|
||||||
|
VERIFY(list0101.size() == 2);
|
||||||
|
VERIFY(T::copyCount() == 2);
|
||||||
|
VERIFY(k->id() == 1);
|
||||||
|
|
||||||
|
list0101.push_back(T(3)); // list should be [2 1 3]
|
||||||
|
VERIFY(list0101.size() == 3);
|
||||||
|
VERIFY(T::copyCount() == 3);
|
||||||
|
VERIFY(k->id() == 1);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list0101.push_back(T(4, true));
|
||||||
|
VERIFY(("no exception thrown", false));
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
VERIFY(list0101.size() == 3);
|
||||||
|
VERIFY(T::copyCount() == 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = list0101.begin();
|
||||||
|
VERIFY(i->id() == 2);
|
||||||
|
VERIFY(i->id() == list0101.front().id());
|
||||||
|
|
||||||
|
j = list0101.rbegin();
|
||||||
|
VERIFY(j->id() == 3);
|
||||||
|
VERIFY(j->id() == list0101.back().id());
|
||||||
|
|
||||||
|
++i;
|
||||||
|
VERIFY(i->id() == 1);
|
||||||
|
|
||||||
|
++j;
|
||||||
|
VERIFY(j->id() == 1);
|
||||||
|
|
||||||
|
T::reset();
|
||||||
|
|
||||||
|
list0101.pop_back(); // list should be [2 1]
|
||||||
|
VERIFY(list0101.size() == 2);
|
||||||
|
VERIFY(T::dtorCount() == 1);
|
||||||
|
VERIFY(i->id() == 1);
|
||||||
|
VERIFY(k->id() == 1);
|
||||||
|
|
||||||
|
list0101.pop_front(); // list should be [1]
|
||||||
|
VERIFY(list0101.size() == 1);
|
||||||
|
VERIFY(T::dtorCount() == 2);
|
||||||
|
VERIFY(i->id() == 1);
|
||||||
|
VERIFY(k->id() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Copyright (C) 2001 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.4 list operations [lib.list.ops]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// splice(p, x) + remove + reverse
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
const int K = 417;
|
||||||
|
const int A[] = {1, 2, 3, 4, 5};
|
||||||
|
const int B[] = {K, K, K, K, K};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
const int M = sizeof(B) / sizeof(int);
|
||||||
|
|
||||||
|
std::list<int> list0101(A, A + N);
|
||||||
|
std::list<int> list0102(B, B + M);
|
||||||
|
std::list<int>::iterator p = list0101.begin();
|
||||||
|
|
||||||
|
VERIFY(list0101.size() == N);
|
||||||
|
VERIFY(list0102.size() == M);
|
||||||
|
|
||||||
|
++p;
|
||||||
|
list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5]
|
||||||
|
VERIFY(list0101.size() == N + M);
|
||||||
|
VERIFY(list0102.size() == 0);
|
||||||
|
|
||||||
|
// remove range from middle
|
||||||
|
list0101.remove(K);
|
||||||
|
VERIFY(list0101.size() == N);
|
||||||
|
|
||||||
|
// remove first element
|
||||||
|
list0101.remove(1);
|
||||||
|
VERIFY(list0101.size() == N - 1);
|
||||||
|
|
||||||
|
// remove last element
|
||||||
|
list0101.remove(5);
|
||||||
|
VERIFY(list0101.size() == N - 2);
|
||||||
|
|
||||||
|
// reverse
|
||||||
|
list0101.reverse();
|
||||||
|
p = list0101.begin();
|
||||||
|
VERIFY(*p == 4); ++p;
|
||||||
|
VERIFY(*p == 3); ++p;
|
||||||
|
VERIFY(*p == 2); ++p;
|
||||||
|
VERIFY(p == list0101.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Copyright (C) 2001 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.4 list operations [lib.list.ops]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// splice(p, x, i) + remove_if + operator==
|
||||||
|
void
|
||||||
|
test02()
|
||||||
|
{
|
||||||
|
const int A[] = {1, 2, 3, 4, 5};
|
||||||
|
const int B[] = {2, 1, 3, 4, 5};
|
||||||
|
const int C[] = {1, 3, 4, 5, 2};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
std::list<int> list0201(A, A + N);
|
||||||
|
std::list<int> list0202(A, A + N);
|
||||||
|
std::list<int> list0203(B, B + N);
|
||||||
|
std::list<int> list0204(C, C + N);
|
||||||
|
std::list<int>::iterator i = list0201.begin();
|
||||||
|
|
||||||
|
// result should be unchanged
|
||||||
|
list0201.splice(list0201.begin(), list0201, i);
|
||||||
|
VERIFY(list0201 == list0202);
|
||||||
|
|
||||||
|
// result should be [2 1 3 4 5]
|
||||||
|
++i;
|
||||||
|
list0201.splice(list0201.begin(), list0201, i);
|
||||||
|
VERIFY(list0201 != list0202);
|
||||||
|
VERIFY(list0201 == list0203);
|
||||||
|
|
||||||
|
// result should be [1 3 4 5 2]
|
||||||
|
list0201.splice(list0201.end(), list0201, i);
|
||||||
|
VERIFY(list0201 == list0204);
|
||||||
|
}
|
||||||
|
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Copyright (C) 2001 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.4 list operations [lib.list.ops]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// splice(p, x, f, l) + sort + merge + unique
|
||||||
|
void
|
||||||
|
test03()
|
||||||
|
{
|
||||||
|
const int A[] = {103, 203, 603, 303, 403, 503};
|
||||||
|
const int B[] = {417, 417, 417, 417, 417};
|
||||||
|
const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
|
||||||
|
const int F[] = {103, 203, 303, 403, 417, 417, 503, 603};
|
||||||
|
const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603};
|
||||||
|
const int D[] = {103, 203, 303, 403, 417, 503, 603};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
const int M = sizeof(B) / sizeof(int);
|
||||||
|
const int P = sizeof(C) / sizeof(int);
|
||||||
|
const int Q = sizeof(D) / sizeof(int);
|
||||||
|
const int R = sizeof(E) / sizeof(int);
|
||||||
|
|
||||||
|
std::list<int> list0301(A, A + N);
|
||||||
|
std::list<int> list0302(B, B + M);
|
||||||
|
std::list<int> list0303(C, C + P);
|
||||||
|
std::list<int> list0304(D, D + Q);
|
||||||
|
std::list<int> list0305(E, E + R);
|
||||||
|
std::list<int> list0306(F, F + R);
|
||||||
|
std::list<int>::iterator p = list0301.begin();
|
||||||
|
std::list<int>::iterator q = list0302.begin();
|
||||||
|
|
||||||
|
++p; ++q; ++q;
|
||||||
|
list0301.splice(p, list0302, list0302.begin(), q);
|
||||||
|
VERIFY(list0301 == list0305);
|
||||||
|
VERIFY(list0301.size() == N + 2);
|
||||||
|
VERIFY(list0302.size() == M - 2);
|
||||||
|
|
||||||
|
list0301.sort();
|
||||||
|
VERIFY(list0301 == list0306);
|
||||||
|
|
||||||
|
list0301.merge(list0302);
|
||||||
|
VERIFY(list0301.size() == N + M);
|
||||||
|
VERIFY(list0302.size() == 0);
|
||||||
|
VERIFY(list0301 == list0303);
|
||||||
|
|
||||||
|
list0301.unique();
|
||||||
|
VERIFY(list0301 == list0304);
|
||||||
|
}
|
||||||
|
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
test03();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -0,0 +1,94 @@
|
||||||
|
// Copyright (C) 2001 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 2, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.2.4 list operations [lib.list.ops]
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
// A comparison predicate to order by rightmost digit. Tracks call counts for
|
||||||
|
// performance checks.
|
||||||
|
struct CompLastLt
|
||||||
|
{
|
||||||
|
bool operator()(const int x, const int y)
|
||||||
|
{ ++itsCount; return x % 10 < y % 10; }
|
||||||
|
static int count() { return itsCount; }
|
||||||
|
static void reset() { itsCount = 0; }
|
||||||
|
static int itsCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
int CompLastLt::itsCount;
|
||||||
|
|
||||||
|
struct CompLastEq
|
||||||
|
{
|
||||||
|
bool operator()(const int x, const int y)
|
||||||
|
{ ++itsCount; return x % 10 == y % 10; }
|
||||||
|
static int count() { return itsCount; }
|
||||||
|
static void reset() { itsCount = 0; }
|
||||||
|
static int itsCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
int CompLastEq::itsCount;
|
||||||
|
|
||||||
|
// sort(pred) + merge(pred) + unique(pred)
|
||||||
|
// also checks performance requirements
|
||||||
|
void
|
||||||
|
test04()
|
||||||
|
{
|
||||||
|
const int A[] = {1, 2, 3, 4, 5, 6};
|
||||||
|
const int B[] = {12, 15, 13, 14, 11};
|
||||||
|
const int C[] = {11, 12, 13, 14, 15};
|
||||||
|
const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
const int M = sizeof(B) / sizeof(int);
|
||||||
|
const int Q = sizeof(D) / sizeof(int);
|
||||||
|
|
||||||
|
std::list<int> list0401(A, A + N);
|
||||||
|
std::list<int> list0402(B, B + M);
|
||||||
|
std::list<int> list0403(C, C + M);
|
||||||
|
std::list<int> list0404(D, D + Q);
|
||||||
|
std::list<int> list0405(A, A + N);
|
||||||
|
|
||||||
|
// sort B
|
||||||
|
CompLastLt lt;
|
||||||
|
|
||||||
|
CompLastLt::reset();
|
||||||
|
list0402.sort(lt);
|
||||||
|
VERIFY(list0402 == list0403);
|
||||||
|
|
||||||
|
CompLastLt::reset();
|
||||||
|
list0401.merge(list0402, lt);
|
||||||
|
VERIFY(list0401 == list0404);
|
||||||
|
VERIFY(lt.count() <= (N + M - 1));
|
||||||
|
|
||||||
|
CompLastEq eq;
|
||||||
|
|
||||||
|
CompLastEq::reset();
|
||||||
|
list0401.unique(eq);
|
||||||
|
VERIFY(list0401 == list0405);
|
||||||
|
VERIFY(eq.count() == (N + M - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
test04();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// vi:set sw=2 ts=2:
|
|
@ -1,332 +0,0 @@
|
||||||
// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
|
|
||||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
||||||
// USA.
|
|
||||||
|
|
||||||
// 23.2.2.1 list constructors, copy, and assignment
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <testsuite_hooks.h>
|
|
||||||
|
|
||||||
bool test = true;
|
|
||||||
|
|
||||||
// A nontrivial type.
|
|
||||||
template<typename T>
|
|
||||||
struct A { };
|
|
||||||
|
|
||||||
// Another nontrivial type
|
|
||||||
struct B { };
|
|
||||||
|
|
||||||
// A nontrivial type convertible from an int
|
|
||||||
struct C {
|
|
||||||
C(int i) : i_(i) { }
|
|
||||||
bool operator==(const C& rhs) { return i_ == rhs.i_; }
|
|
||||||
int i_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Default constructor, basic properties
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2.1 explicit list(const a& = Allocator())
|
|
||||||
// 23.1 (7) iterator behaviour of empty containers
|
|
||||||
// 23.2.2 iterator begin()
|
|
||||||
// 23.2.2 iterator end()
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
// 23.2.2 existence of required typedefs
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test01()
|
|
||||||
{
|
|
||||||
std::list< A<B> > list0101;
|
|
||||||
VERIFY(list0101.begin() == list0101.end());
|
|
||||||
VERIFY(list0101.size() == 0);
|
|
||||||
|
|
||||||
// check type definitions -- will fail compile if missing
|
|
||||||
typedef std::list< A<B> >::reference reference;
|
|
||||||
typedef std::list< A<B> >::const_reference const_reference;
|
|
||||||
typedef std::list< A<B> >::iterator iterator;
|
|
||||||
typedef std::list< A<B> >::const_iterator const_iterator;
|
|
||||||
typedef std::list< A<B> >::size_type size_type;
|
|
||||||
typedef std::list< A<B> >::difference_type difference_type;
|
|
||||||
typedef std::list< A<B> >::value_type value_type;
|
|
||||||
typedef std::list< A<B> >::allocator_type allocator_type;
|
|
||||||
typedef std::list< A<B> >::pointer pointer;
|
|
||||||
typedef std::list< A<B> >::const_pointer const_pointer;
|
|
||||||
typedef std::list< A<B> >::reverse_iterator reverse_iterator;
|
|
||||||
typedef std::list< A<B> >::const_reverse_iterator const_reverse_iterator;
|
|
||||||
|
|
||||||
// allocator checks?
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill constructor
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator())
|
|
||||||
// 23.2.2 const_iterator begin() const
|
|
||||||
// 23.2.2 const_iterator end() const
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test02()
|
|
||||||
{
|
|
||||||
const int LIST_SIZE = 5;
|
|
||||||
const int INIT_VALUE = 7;
|
|
||||||
int count;
|
|
||||||
std::list<int>::const_iterator i;
|
|
||||||
|
|
||||||
// nontrivial value_type
|
|
||||||
std::list< A<B> > list0201(LIST_SIZE);
|
|
||||||
|
|
||||||
// default value
|
|
||||||
std::list<int> list0202(LIST_SIZE);
|
|
||||||
for (i = list0202.begin(), count = 0;
|
|
||||||
i != list0202.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == 0);
|
|
||||||
VERIFY(count == LIST_SIZE);
|
|
||||||
VERIFY(list0202.size() == LIST_SIZE);
|
|
||||||
|
|
||||||
// explicit value
|
|
||||||
std::list<int> list0203(LIST_SIZE, INIT_VALUE);
|
|
||||||
for (i = list0203.begin(), count = 0;
|
|
||||||
i != list0203.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == INIT_VALUE);
|
|
||||||
VERIFY(count == LIST_SIZE);
|
|
||||||
VERIFY(list0203.size() == LIST_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill constructor disguised as a range constructor
|
|
||||||
void
|
|
||||||
test02D()
|
|
||||||
{
|
|
||||||
const int LIST_SIZE = 5;
|
|
||||||
const int INIT_VALUE = 7;
|
|
||||||
int count = 0;
|
|
||||||
std::list<C> list0204(LIST_SIZE, INIT_VALUE);
|
|
||||||
std::list<C>::iterator i = list0204.begin();
|
|
||||||
for (; i != list0204.end(); ++i, ++count)
|
|
||||||
VERIFY(*i == INIT_VALUE);
|
|
||||||
VERIFY(count == LIST_SIZE);
|
|
||||||
VERIFY(list0204.size() == LIST_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Range constructor
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2.1 template list(InputIterator f, InputIterator l, const Allocator& a = Allocator())
|
|
||||||
// 23.2.2 const_iterator begin() const
|
|
||||||
// 23.2.2 const_iterator end() const
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test03()
|
|
||||||
{
|
|
||||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
int count;
|
|
||||||
std::list<int>::const_iterator i;
|
|
||||||
|
|
||||||
// construct from a dissimilar range
|
|
||||||
std::list<int> list0301(A, A + N);
|
|
||||||
for (i = list0301.begin(), count = 0;
|
|
||||||
i != list0301.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == A[count]);
|
|
||||||
VERIFY(count == N);
|
|
||||||
VERIFY(list0301.size() == N);
|
|
||||||
|
|
||||||
// construct from a similar range
|
|
||||||
std::list<int> list0302(list0301.begin(), list0301.end());
|
|
||||||
for (i = list0302.begin(), count = 0;
|
|
||||||
i != list0302.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == A[count]);
|
|
||||||
VERIFY(count == N);
|
|
||||||
VERIFY(list0302.size() == N);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy constructor
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2.1 list(const list& x)
|
|
||||||
// 23.2.2 reverse_iterator rbegin()
|
|
||||||
// 23.2.2 reverse_iterator rend()
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test04()
|
|
||||||
{
|
|
||||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
int count;
|
|
||||||
std::list<int>::reverse_iterator i;
|
|
||||||
std::list<int> list0401(A, A + N);
|
|
||||||
|
|
||||||
std::list<int> list0402(list0401);
|
|
||||||
for (i = list0401.rbegin(), count = N - 1;
|
|
||||||
i != list0401.rend();
|
|
||||||
++i, --count)
|
|
||||||
VERIFY(*i == A[count]);
|
|
||||||
VERIFY(count == -1);
|
|
||||||
VERIFY(list0401.size() == N);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Range assign
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2.1 void assign(InputIterator f, InputIterator l)
|
|
||||||
// 23.2.2 const_iterator begin() const
|
|
||||||
// 23.2.2 const_iterator end() const
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test05()
|
|
||||||
{
|
|
||||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
|
||||||
const int B[] = {101, 102, 103, 104, 105};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
const int M = sizeof(B) / sizeof(int);
|
|
||||||
int count;
|
|
||||||
std::list<int>::const_iterator i;
|
|
||||||
|
|
||||||
std::list<int> list0501;
|
|
||||||
|
|
||||||
// make it bigger
|
|
||||||
list0501.assign(A, A + N);
|
|
||||||
for (i = list0501.begin(), count = 0;
|
|
||||||
i != list0501.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == A[count]);
|
|
||||||
VERIFY(count == N);
|
|
||||||
VERIFY(list0501.size() == N);
|
|
||||||
|
|
||||||
// make it smaller
|
|
||||||
list0501.assign(B, B + M);
|
|
||||||
for (i = list0501.begin(), count = 0;
|
|
||||||
i != list0501.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == B[count]);
|
|
||||||
VERIFY(count == M);
|
|
||||||
VERIFY(list0501.size() == M);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill assign
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2.1 void assign(size_type n, const T& v)
|
|
||||||
// 23.2.2 const_iterator begin() const
|
|
||||||
// 23.2.2 const_iterator end() const
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test06()
|
|
||||||
{
|
|
||||||
const int BIG_LIST_SIZE = 11;
|
|
||||||
const int BIG_INIT_VALUE = 7;
|
|
||||||
const int SMALL_LIST_SIZE = 5;
|
|
||||||
const int SMALL_INIT_VALUE = 17;
|
|
||||||
int count;
|
|
||||||
std::list<int>::const_iterator i;
|
|
||||||
|
|
||||||
std::list<int> list0601;
|
|
||||||
VERIFY(list0601.size() == 0);
|
|
||||||
|
|
||||||
// make it bigger
|
|
||||||
list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE);
|
|
||||||
for (i = list0601.begin(), count = 0;
|
|
||||||
i != list0601.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == BIG_INIT_VALUE);
|
|
||||||
VERIFY(count == BIG_LIST_SIZE);
|
|
||||||
VERIFY(list0601.size() == BIG_LIST_SIZE);
|
|
||||||
|
|
||||||
// make it shrink
|
|
||||||
list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE);
|
|
||||||
for (i = list0601.begin(), count = 0;
|
|
||||||
i != list0601.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == SMALL_INIT_VALUE);
|
|
||||||
VERIFY(count == SMALL_LIST_SIZE);
|
|
||||||
VERIFY(list0601.size() == SMALL_LIST_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill Assignment disguised as a Range Assignment
|
|
||||||
void
|
|
||||||
test06D()
|
|
||||||
{
|
|
||||||
const int LIST_SIZE = 5;
|
|
||||||
const int INIT_VALUE = 7;
|
|
||||||
int count = 0;
|
|
||||||
std::list<C> list0604;
|
|
||||||
VERIFY(list0604.size() == 0);
|
|
||||||
|
|
||||||
list0604.assign(LIST_SIZE, INIT_VALUE);
|
|
||||||
std::list<C>::iterator i = list0604.begin();
|
|
||||||
for (; i != list0604.end(); ++i, ++count)
|
|
||||||
VERIFY(*i == INIT_VALUE);
|
|
||||||
VERIFY(count == LIST_SIZE);
|
|
||||||
VERIFY(list0604.size() == LIST_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assignment operator
|
|
||||||
//
|
|
||||||
// This test verifies the following.
|
|
||||||
// 23.2.2 operator=(const list& x)
|
|
||||||
// 23.2.2 iterator begin()
|
|
||||||
// 23.2.2 iterator end()
|
|
||||||
// 23.2.2 size_type size() const
|
|
||||||
// 23.2.2 bool operator==(const list& x, const list& y)
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test07()
|
|
||||||
{
|
|
||||||
const int A[] = {701, 702, 703, 704, 705};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
int count;
|
|
||||||
std::list<int>::iterator i;
|
|
||||||
|
|
||||||
std::list<int> list0701(A, A + N);
|
|
||||||
VERIFY(list0701.size() == N);
|
|
||||||
|
|
||||||
std::list<int> list0702;
|
|
||||||
VERIFY(list0702.size() == 0);
|
|
||||||
|
|
||||||
list0702 = list0701;
|
|
||||||
VERIFY(list0702.size() == N);
|
|
||||||
for (i = list0702.begin(), count = 0;
|
|
||||||
i != list0702.end();
|
|
||||||
++i, ++count)
|
|
||||||
VERIFY(*i == A[count]);
|
|
||||||
VERIFY(count == N);
|
|
||||||
VERIFY(list0702 == list0701);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
test01();
|
|
||||||
test02();
|
|
||||||
test02D();
|
|
||||||
test03();
|
|
||||||
test04();
|
|
||||||
test05();
|
|
||||||
test06();
|
|
||||||
test06D();
|
|
||||||
test07();
|
|
||||||
|
|
||||||
return !test;
|
|
||||||
}
|
|
||||||
// vi:set sw=2 ts=2:
|
|
|
@ -1,273 +0,0 @@
|
||||||
// Copyright (C) 2001, 2003 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 2, or (at your option)
|
|
||||||
// any later version.
|
|
||||||
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
|
||||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
||||||
// USA.
|
|
||||||
|
|
||||||
// 23.2.2.3 list modifiers [lib.list.modifiers]
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <testsuite_hooks.h>
|
|
||||||
|
|
||||||
typedef __gnu_test::copy_tracker T;
|
|
||||||
|
|
||||||
bool test = true;
|
|
||||||
|
|
||||||
|
|
||||||
// This test verifies the following.
|
|
||||||
//
|
|
||||||
// 23.2.2.3 void push_front(const T& x)
|
|
||||||
// 23.2.2.3 void push_back(const T& x)
|
|
||||||
// 23.2.2.3 (1) iterator and reference non-invalidation
|
|
||||||
// 23.2.2.3 (1) exception effects
|
|
||||||
// 23.2.2.3 (2) complexity requirements
|
|
||||||
//
|
|
||||||
// 23.2.2.3 void pop_front()
|
|
||||||
// 23.2.2.3 void pop_back()
|
|
||||||
// 23.2.2.3 (3) iterator and reference non-invalidation
|
|
||||||
// 23.2.2.3 (5) complexity requirements
|
|
||||||
//
|
|
||||||
// 23.2.2 const_iterator begin() const
|
|
||||||
// 23.2.2 iterator end()
|
|
||||||
// 23.2.2 const_reverse_iterator rbegin() const
|
|
||||||
// 23.2.2 _reference front()
|
|
||||||
// 23.2.2 const_reference front() const
|
|
||||||
// 23.2.2 reference back()
|
|
||||||
// 23.2.2 const_reference back() const
|
|
||||||
//
|
|
||||||
void
|
|
||||||
test01()
|
|
||||||
{
|
|
||||||
std::list<T> list0101;
|
|
||||||
std::list<T>::const_iterator i;
|
|
||||||
std::list<T>::const_reverse_iterator j;
|
|
||||||
std::list<T>::iterator k;
|
|
||||||
T::reset();
|
|
||||||
|
|
||||||
list0101.push_back(T(1)); // list should be [1]
|
|
||||||
VERIFY(list0101.size() == 1);
|
|
||||||
VERIFY(T::copyCount() == 1);
|
|
||||||
|
|
||||||
k = list0101.end();
|
|
||||||
--k;
|
|
||||||
VERIFY(k->id() == 1);
|
|
||||||
VERIFY(k->id() == list0101.front().id());
|
|
||||||
VERIFY(k->id() == list0101.back().id());
|
|
||||||
|
|
||||||
list0101.push_front(T(2)); // list should be [2 1]
|
|
||||||
VERIFY(list0101.size() == 2);
|
|
||||||
VERIFY(T::copyCount() == 2);
|
|
||||||
VERIFY(k->id() == 1);
|
|
||||||
|
|
||||||
list0101.push_back(T(3)); // list should be [2 1 3]
|
|
||||||
VERIFY(list0101.size() == 3);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
VERIFY(k->id() == 1);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
list0101.push_back(T(4, true));
|
|
||||||
VERIFY(("no exception thrown", false));
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
VERIFY(list0101.size() == 3);
|
|
||||||
VERIFY(T::copyCount() == 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
i = list0101.begin();
|
|
||||||
VERIFY(i->id() == 2);
|
|
||||||
VERIFY(i->id() == list0101.front().id());
|
|
||||||
|
|
||||||
j = list0101.rbegin();
|
|
||||||
VERIFY(j->id() == 3);
|
|
||||||
VERIFY(j->id() == list0101.back().id());
|
|
||||||
|
|
||||||
++i;
|
|
||||||
VERIFY(i->id() == 1);
|
|
||||||
|
|
||||||
++j;
|
|
||||||
VERIFY(j->id() == 1);
|
|
||||||
|
|
||||||
T::reset();
|
|
||||||
|
|
||||||
list0101.pop_back(); // list should be [2 1]
|
|
||||||
VERIFY(list0101.size() == 2);
|
|
||||||
VERIFY(T::dtorCount() == 1);
|
|
||||||
VERIFY(i->id() == 1);
|
|
||||||
VERIFY(k->id() == 1);
|
|
||||||
|
|
||||||
list0101.pop_front(); // list should be [1]
|
|
||||||
VERIFY(list0101.size() == 1);
|
|
||||||
VERIFY(T::dtorCount() == 2);
|
|
||||||
VERIFY(i->id() == 1);
|
|
||||||
VERIFY(k->id() == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// general single insert/erase + swap
|
|
||||||
void
|
|
||||||
test02()
|
|
||||||
{
|
|
||||||
std::list<T> list0201;
|
|
||||||
T::reset();
|
|
||||||
|
|
||||||
list0201.insert(list0201.begin(), T(1)); // list should be [1]
|
|
||||||
VERIFY(list0201.size() == 1);
|
|
||||||
VERIFY(T::copyCount() == 1);
|
|
||||||
|
|
||||||
list0201.insert(list0201.end(), T(2)); // list should be [1 2]
|
|
||||||
VERIFY(list0201.size() == 2);
|
|
||||||
VERIFY(T::copyCount() == 2);
|
|
||||||
|
|
||||||
std::list<T>::iterator i = list0201.begin();
|
|
||||||
std::list<T>::const_iterator j = i;
|
|
||||||
VERIFY(i->id() == 1); ++i;
|
|
||||||
VERIFY(i->id() == 2);
|
|
||||||
|
|
||||||
list0201.insert(i, T(3)); // list should be [1 3 2]
|
|
||||||
VERIFY(list0201.size() == 3);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
|
|
||||||
std::list<T>::const_iterator k = i;
|
|
||||||
VERIFY(i->id() == 2); --i;
|
|
||||||
VERIFY(i->id() == 3); --i;
|
|
||||||
VERIFY(i->id() == 1);
|
|
||||||
VERIFY(j->id() == 1);
|
|
||||||
|
|
||||||
++i; // will point to '3'
|
|
||||||
T::reset();
|
|
||||||
list0201.erase(i); // should be [1 2]
|
|
||||||
VERIFY(list0201.size() == 2);
|
|
||||||
VERIFY(T::dtorCount() == 1);
|
|
||||||
VERIFY(k->id() == 2);
|
|
||||||
VERIFY(j->id() == 1);
|
|
||||||
|
|
||||||
std::list<T> list0202;
|
|
||||||
T::reset();
|
|
||||||
VERIFY(list0202.size() == 0);
|
|
||||||
VERIFY(T::copyCount() == 0);
|
|
||||||
VERIFY(T::dtorCount() == 0);
|
|
||||||
|
|
||||||
// member swap
|
|
||||||
list0202.swap(list0201);
|
|
||||||
VERIFY(list0201.size() == 0);
|
|
||||||
VERIFY(list0202.size() == 2);
|
|
||||||
VERIFY(T::copyCount() == 0);
|
|
||||||
VERIFY(T::dtorCount() == 0);
|
|
||||||
|
|
||||||
// specialized swap
|
|
||||||
swap(list0201, list0202);
|
|
||||||
VERIFY(list0201.size() == 2);
|
|
||||||
VERIFY(list0202.size() == 0);
|
|
||||||
VERIFY(T::copyCount() == 0);
|
|
||||||
VERIFY(T::dtorCount() == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// range and fill insert/erase + clear
|
|
||||||
// missing: o fill insert disguised as a range insert in all its variants
|
|
||||||
// o exception effects
|
|
||||||
void
|
|
||||||
test03()
|
|
||||||
{
|
|
||||||
std::list<T> list0301;
|
|
||||||
T::reset();
|
|
||||||
|
|
||||||
// fill insert at beginning of list / empty list
|
|
||||||
list0301.insert(list0301.begin(), 3, T(11)); // should be [11 11 11]
|
|
||||||
VERIFY(list0301.size() == 3);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
|
|
||||||
// save iterators to verify post-insert validity
|
|
||||||
std::list<T>::iterator b = list0301.begin();
|
|
||||||
std::list<T>::iterator m = list0301.end(); --m;
|
|
||||||
std::list<T>::iterator e = list0301.end();
|
|
||||||
|
|
||||||
// fill insert at end of list
|
|
||||||
T::reset();
|
|
||||||
list0301.insert(list0301.end(), 3, T(13)); // should be [11 11 11 13 13 13]
|
|
||||||
VERIFY(list0301.size() == 6);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
VERIFY(b == list0301.begin() && b->id() == 11);
|
|
||||||
VERIFY(e == list0301.end());
|
|
||||||
VERIFY(m->id() == 11);
|
|
||||||
|
|
||||||
// fill insert in the middle of list
|
|
||||||
++m;
|
|
||||||
T::reset();
|
|
||||||
list0301.insert(m, 3, T(12)); // should be [11 11 11 12 12 12 13 13 13]
|
|
||||||
VERIFY(list0301.size() == 9);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
VERIFY(b == list0301.begin() && b->id() == 11);
|
|
||||||
VERIFY(e == list0301.end());
|
|
||||||
VERIFY(m->id() == 13);
|
|
||||||
|
|
||||||
// single erase
|
|
||||||
T::reset();
|
|
||||||
m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
|
|
||||||
VERIFY(list0301.size() == 8);
|
|
||||||
VERIFY(T::dtorCount() == 1);
|
|
||||||
VERIFY(b == list0301.begin() && b->id() == 11);
|
|
||||||
VERIFY(e == list0301.end());
|
|
||||||
VERIFY(m->id() == 13);
|
|
||||||
|
|
||||||
// range erase
|
|
||||||
T::reset();
|
|
||||||
m = list0301.erase(list0301.begin(), m); // should be [13 13]
|
|
||||||
VERIFY(list0301.size() == 2);
|
|
||||||
VERIFY(T::dtorCount() == 6);
|
|
||||||
VERIFY(m->id() == 13);
|
|
||||||
|
|
||||||
// range fill at beginning
|
|
||||||
const int A[] = {321, 322, 333};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
T::reset();
|
|
||||||
b = list0301.begin();
|
|
||||||
list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
|
|
||||||
VERIFY(list0301.size() == 5);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
VERIFY(m->id() == 13);
|
|
||||||
|
|
||||||
// range fill at end
|
|
||||||
T::reset();
|
|
||||||
list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
|
|
||||||
VERIFY(list0301.size() == 8);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
VERIFY(e == list0301.end());
|
|
||||||
VERIFY(m->id() == 13);
|
|
||||||
|
|
||||||
// range fill in middle
|
|
||||||
T::reset();
|
|
||||||
list0301.insert(m, A, A + N);
|
|
||||||
VERIFY(list0301.size() == 11);
|
|
||||||
VERIFY(T::copyCount() == 3);
|
|
||||||
VERIFY(e == list0301.end());
|
|
||||||
VERIFY(m->id() == 13);
|
|
||||||
|
|
||||||
T::reset();
|
|
||||||
list0301.clear();
|
|
||||||
VERIFY(list0301.size() == 0);
|
|
||||||
VERIFY(T::dtorCount() == 11);
|
|
||||||
VERIFY(e == list0301.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
test01();
|
|
||||||
test02();
|
|
||||||
test03();
|
|
||||||
|
|
||||||
return !test;
|
|
||||||
}
|
|
||||||
// vi:set sw=2 ts=2:
|
|
|
@ -1,211 +0,0 @@
|
||||||
// Copyright (C) 2001 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 2, or (at your option)
|
|
||||||
// any later version.
|
|
||||||
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without Pred 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 COPYING. If not, write to the Free
|
|
||||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
||||||
// USA.
|
|
||||||
|
|
||||||
// 23.2.2.4 list operations [lib.list.ops]
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <testsuite_hooks.h>
|
|
||||||
|
|
||||||
bool test = true;
|
|
||||||
|
|
||||||
// splice(p, x) + remove + reverse
|
|
||||||
void
|
|
||||||
test01()
|
|
||||||
{
|
|
||||||
const int K = 417;
|
|
||||||
const int A[] = {1, 2, 3, 4, 5};
|
|
||||||
const int B[] = {K, K, K, K, K};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
const int M = sizeof(B) / sizeof(int);
|
|
||||||
|
|
||||||
std::list<int> list0101(A, A + N);
|
|
||||||
std::list<int> list0102(B, B + M);
|
|
||||||
std::list<int>::iterator p = list0101.begin();
|
|
||||||
|
|
||||||
VERIFY(list0101.size() == N);
|
|
||||||
VERIFY(list0102.size() == M);
|
|
||||||
|
|
||||||
++p;
|
|
||||||
list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5]
|
|
||||||
VERIFY(list0101.size() == N + M);
|
|
||||||
VERIFY(list0102.size() == 0);
|
|
||||||
|
|
||||||
// remove range from middle
|
|
||||||
list0101.remove(K);
|
|
||||||
VERIFY(list0101.size() == N);
|
|
||||||
|
|
||||||
// remove first element
|
|
||||||
list0101.remove(1);
|
|
||||||
VERIFY(list0101.size() == N - 1);
|
|
||||||
|
|
||||||
// remove last element
|
|
||||||
list0101.remove(5);
|
|
||||||
VERIFY(list0101.size() == N - 2);
|
|
||||||
|
|
||||||
// reverse
|
|
||||||
list0101.reverse();
|
|
||||||
p = list0101.begin();
|
|
||||||
VERIFY(*p == 4); ++p;
|
|
||||||
VERIFY(*p == 3); ++p;
|
|
||||||
VERIFY(*p == 2); ++p;
|
|
||||||
VERIFY(p == list0101.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// splice(p, x, i) + remove_if + operator==
|
|
||||||
void
|
|
||||||
test02()
|
|
||||||
{
|
|
||||||
const int A[] = {1, 2, 3, 4, 5};
|
|
||||||
const int B[] = {2, 1, 3, 4, 5};
|
|
||||||
const int C[] = {1, 3, 4, 5, 2};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
std::list<int> list0201(A, A + N);
|
|
||||||
std::list<int> list0202(A, A + N);
|
|
||||||
std::list<int> list0203(B, B + N);
|
|
||||||
std::list<int> list0204(C, C + N);
|
|
||||||
std::list<int>::iterator i = list0201.begin();
|
|
||||||
|
|
||||||
// result should be unchanged
|
|
||||||
list0201.splice(list0201.begin(), list0201, i);
|
|
||||||
VERIFY(list0201 == list0202);
|
|
||||||
|
|
||||||
// result should be [2 1 3 4 5]
|
|
||||||
++i;
|
|
||||||
list0201.splice(list0201.begin(), list0201, i);
|
|
||||||
VERIFY(list0201 != list0202);
|
|
||||||
VERIFY(list0201 == list0203);
|
|
||||||
|
|
||||||
// result should be [1 3 4 5 2]
|
|
||||||
list0201.splice(list0201.end(), list0201, i);
|
|
||||||
VERIFY(list0201 == list0204);
|
|
||||||
}
|
|
||||||
|
|
||||||
// splice(p, x, f, l) + sort + merge + unique
|
|
||||||
void
|
|
||||||
test03()
|
|
||||||
{
|
|
||||||
const int A[] = {103, 203, 603, 303, 403, 503};
|
|
||||||
const int B[] = {417, 417, 417, 417, 417};
|
|
||||||
const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
|
|
||||||
const int F[] = {103, 203, 303, 403, 417, 417, 503, 603};
|
|
||||||
const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603};
|
|
||||||
const int D[] = {103, 203, 303, 403, 417, 503, 603};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
const int M = sizeof(B) / sizeof(int);
|
|
||||||
const int P = sizeof(C) / sizeof(int);
|
|
||||||
const int Q = sizeof(D) / sizeof(int);
|
|
||||||
const int R = sizeof(E) / sizeof(int);
|
|
||||||
|
|
||||||
std::list<int> list0301(A, A + N);
|
|
||||||
std::list<int> list0302(B, B + M);
|
|
||||||
std::list<int> list0303(C, C + P);
|
|
||||||
std::list<int> list0304(D, D + Q);
|
|
||||||
std::list<int> list0305(E, E + R);
|
|
||||||
std::list<int> list0306(F, F + R);
|
|
||||||
std::list<int>::iterator p = list0301.begin();
|
|
||||||
std::list<int>::iterator q = list0302.begin();
|
|
||||||
|
|
||||||
++p; ++q; ++q;
|
|
||||||
list0301.splice(p, list0302, list0302.begin(), q);
|
|
||||||
VERIFY(list0301 == list0305);
|
|
||||||
VERIFY(list0301.size() == N + 2);
|
|
||||||
VERIFY(list0302.size() == M - 2);
|
|
||||||
|
|
||||||
list0301.sort();
|
|
||||||
VERIFY(list0301 == list0306);
|
|
||||||
|
|
||||||
list0301.merge(list0302);
|
|
||||||
VERIFY(list0301.size() == N + M);
|
|
||||||
VERIFY(list0302.size() == 0);
|
|
||||||
VERIFY(list0301 == list0303);
|
|
||||||
|
|
||||||
list0301.unique();
|
|
||||||
VERIFY(list0301 == list0304);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A comparison predicate to order by rightmost digit. Tracks call counts for
|
|
||||||
// performance checks.
|
|
||||||
struct CompLastLt
|
|
||||||
{
|
|
||||||
bool operator()(const int x, const int y) { ++itsCount; return x % 10 < y % 10; }
|
|
||||||
static int count() { return itsCount; }
|
|
||||||
static void reset() { itsCount = 0; }
|
|
||||||
static int itsCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CompLastLt::itsCount;
|
|
||||||
|
|
||||||
struct CompLastEq
|
|
||||||
{
|
|
||||||
bool operator()(const int x, const int y) { ++itsCount; return x % 10 == y % 10; }
|
|
||||||
static int count() { return itsCount; }
|
|
||||||
static void reset() { itsCount = 0; }
|
|
||||||
static int itsCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
int CompLastEq::itsCount;
|
|
||||||
|
|
||||||
// sort(pred) + merge(pred) + unique(pred)
|
|
||||||
// also checks performance requirements
|
|
||||||
void
|
|
||||||
test04()
|
|
||||||
{
|
|
||||||
const int A[] = {1, 2, 3, 4, 5, 6};
|
|
||||||
const int B[] = {12, 15, 13, 14, 11};
|
|
||||||
const int C[] = {11, 12, 13, 14, 15};
|
|
||||||
const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
const int M = sizeof(B) / sizeof(int);
|
|
||||||
const int Q = sizeof(D) / sizeof(int);
|
|
||||||
|
|
||||||
std::list<int> list0401(A, A + N);
|
|
||||||
std::list<int> list0402(B, B + M);
|
|
||||||
std::list<int> list0403(C, C + M);
|
|
||||||
std::list<int> list0404(D, D + Q);
|
|
||||||
std::list<int> list0405(A, A + N);
|
|
||||||
|
|
||||||
// sort B
|
|
||||||
CompLastLt lt;
|
|
||||||
|
|
||||||
CompLastLt::reset();
|
|
||||||
list0402.sort(lt);
|
|
||||||
VERIFY(list0402 == list0403);
|
|
||||||
|
|
||||||
CompLastLt::reset();
|
|
||||||
list0401.merge(list0402, lt);
|
|
||||||
VERIFY(list0401 == list0404);
|
|
||||||
VERIFY(lt.count() <= (N + M - 1));
|
|
||||||
|
|
||||||
CompLastEq eq;
|
|
||||||
|
|
||||||
CompLastEq::reset();
|
|
||||||
list0401.unique(eq);
|
|
||||||
VERIFY(list0401 == list0405);
|
|
||||||
VERIFY(eq.count() == (N + M - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
test01();
|
|
||||||
test02();
|
|
||||||
test03();
|
|
||||||
test04();
|
|
||||||
|
|
||||||
return !test;
|
|
||||||
}
|
|
||||||
// vi:set sw=2 ts=2:
|
|
|
@ -21,33 +21,8 @@
|
||||||
// 23.2.3 container adaptros
|
// 23.2.3 container adaptros
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <stack>
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
// libstdc++/7157
|
|
||||||
void
|
|
||||||
test01()
|
|
||||||
{
|
|
||||||
std::queue<int> q;
|
|
||||||
|
|
||||||
q.push(1);
|
|
||||||
q.front();
|
|
||||||
q.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// libstdc++/7158
|
|
||||||
void
|
|
||||||
test02()
|
|
||||||
{
|
|
||||||
std::stack<int> st;
|
|
||||||
|
|
||||||
st.push(1);
|
|
||||||
st.top() = 42;
|
|
||||||
st.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// libstdc++/7161
|
// libstdc++/7161
|
||||||
void
|
void
|
||||||
test03()
|
test03()
|
||||||
|
@ -68,12 +43,8 @@ test03()
|
||||||
pq.pop();
|
pq.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
|
||||||
test02();
|
|
||||||
test03();
|
test03();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
// 2002-06-28 pme
|
||||||
|
|
||||||
|
// Copyright (C) 2002 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.3 container adaptros
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// libstdc++/7157
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::queue<int> q;
|
||||||
|
|
||||||
|
q.push(1);
|
||||||
|
q.front();
|
||||||
|
q.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
// 2002-06-28 pme
|
||||||
|
|
||||||
|
// Copyright (C) 2002 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.3 container adaptros
|
||||||
|
|
||||||
|
#include <stack>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// libstdc++/7158
|
||||||
|
void
|
||||||
|
test02()
|
||||||
|
{
|
||||||
|
std::stack<int> st;
|
||||||
|
|
||||||
|
st.push(1);
|
||||||
|
st.top() = 42;
|
||||||
|
st.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
// 2002-03-05 Stephen M. Webb <stephen.webb@bregmasoft.com>
|
||||||
|
|
||||||
|
// Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.5 class vector<bool>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
std::vector<bool>::iterator i;
|
||||||
|
if (false)
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -23,13 +23,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
void test01()
|
|
||||||
{
|
|
||||||
std::vector<bool>::iterator i;
|
|
||||||
if (false)
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// libstdc++/6886
|
// libstdc++/6886
|
||||||
void test02()
|
void test02()
|
||||||
{
|
{
|
||||||
|
@ -56,7 +49,6 @@ void test02()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
|
||||||
test02();
|
test02();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
// 1999-05-07
|
||||||
|
// bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.2 vector capacity
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
// non POD types
|
||||||
|
bool test = true;
|
||||||
|
std::vector< A<B> > vec01;
|
||||||
|
typedef std::vector< A<B> >::size_type size_type;
|
||||||
|
|
||||||
|
size_type sz01 = vec01.capacity();
|
||||||
|
vec01.reserve(100);
|
||||||
|
size_type sz02 = vec01.capacity();
|
||||||
|
VERIFY( sz02 >= sz01 );
|
||||||
|
|
||||||
|
sz01 = vec01.size() + 5;
|
||||||
|
vec01.resize(sz01);
|
||||||
|
sz02 = vec01.size();
|
||||||
|
VERIFY( sz01 == sz02 );
|
||||||
|
|
||||||
|
sz01 = vec01.size() - 5;
|
||||||
|
vec01.resize(sz01);
|
||||||
|
sz02 = vec01.size();
|
||||||
|
VERIFY( sz01 == sz02 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -33,79 +33,6 @@ using __gnu_test::copy_constructor;
|
||||||
using __gnu_test::assignment_operator;
|
using __gnu_test::assignment_operator;
|
||||||
using __gnu_test::destructor;
|
using __gnu_test::destructor;
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct A { };
|
|
||||||
|
|
||||||
struct B { };
|
|
||||||
|
|
||||||
void test01()
|
|
||||||
{
|
|
||||||
// non POD types
|
|
||||||
bool test = true;
|
|
||||||
std::vector< A<B> > vec01;
|
|
||||||
typedef std::vector< A<B> >::size_type size_type;
|
|
||||||
|
|
||||||
size_type sz01 = vec01.capacity();
|
|
||||||
vec01.reserve(100);
|
|
||||||
size_type sz02 = vec01.capacity();
|
|
||||||
VERIFY( sz02 >= sz01 );
|
|
||||||
|
|
||||||
sz01 = vec01.size() + 5;
|
|
||||||
vec01.resize(sz01);
|
|
||||||
sz02 = vec01.size();
|
|
||||||
VERIFY( sz01 == sz02 );
|
|
||||||
|
|
||||||
sz01 = vec01.size() - 5;
|
|
||||||
vec01.resize(sz01);
|
|
||||||
sz02 = vec01.size();
|
|
||||||
VERIFY( sz01 == sz02 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// libstdc++/8230
|
|
||||||
void test02()
|
|
||||||
{
|
|
||||||
bool test = true;
|
|
||||||
{
|
|
||||||
std::vector<int> array;
|
|
||||||
const std::size_t size = array.max_size();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
array.reserve(size);
|
|
||||||
}
|
|
||||||
catch (const std::length_error& error)
|
|
||||||
{
|
|
||||||
test &= false;
|
|
||||||
}
|
|
||||||
catch (const std::bad_alloc& error)
|
|
||||||
{
|
|
||||||
test &= true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
test &= false;
|
|
||||||
}
|
|
||||||
VERIFY( test );
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::vector<int> array;
|
|
||||||
const std::size_t size = array.max_size() + 1;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
array.reserve(size);
|
|
||||||
}
|
|
||||||
catch (const std::length_error& error)
|
|
||||||
{
|
|
||||||
test &= true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
test &= false;
|
|
||||||
}
|
|
||||||
VERIFY( test );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifies basic functionality of reserve() with forced reallocation.
|
// Verifies basic functionality of reserve() with forced reallocation.
|
||||||
void
|
void
|
||||||
test_reserve()
|
test_reserve()
|
||||||
|
@ -170,8 +97,6 @@ test_reserve_exception_guarantee()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
|
||||||
test02();
|
|
||||||
test_reserve();
|
test_reserve();
|
||||||
test_reserve_exception_guarantee();
|
test_reserve_exception_guarantee();
|
||||||
return 0;
|
return 0;
|
|
@ -0,0 +1,78 @@
|
||||||
|
// 1999-05-07
|
||||||
|
// bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.2 vector capacity
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// libstdc++/8230
|
||||||
|
void test02()
|
||||||
|
{
|
||||||
|
bool test = true;
|
||||||
|
{
|
||||||
|
std::vector<int> array;
|
||||||
|
const std::size_t size = array.max_size();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
array.reserve(size);
|
||||||
|
}
|
||||||
|
catch (const std::length_error& error)
|
||||||
|
{
|
||||||
|
test &= false;
|
||||||
|
}
|
||||||
|
catch (const std::bad_alloc& error)
|
||||||
|
{
|
||||||
|
test &= true;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
test &= false;
|
||||||
|
}
|
||||||
|
VERIFY( test );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<int> array;
|
||||||
|
const std::size_t size = array.max_size() + 1;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
array.reserve(size);
|
||||||
|
}
|
||||||
|
catch (const std::length_error& error)
|
||||||
|
{
|
||||||
|
test &= true;
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
test &= false;
|
||||||
|
}
|
||||||
|
VERIFY( test );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
// 1999-06-29 bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999-2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.1 vector constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
void test01()
|
||||||
|
{
|
||||||
|
// 1
|
||||||
|
std::vector< A<B> > vec01;
|
||||||
|
std::vector< A<B> > vec02(5);
|
||||||
|
typedef std::vector< A<B> >::size_type size_type;
|
||||||
|
|
||||||
|
vec01 = vec02;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
// 1999-06-29 bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999-2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.1 vector constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
// 2
|
||||||
|
template class std::vector<double>;
|
||||||
|
template class std::vector< A<B> >;
|
||||||
|
|
||||||
|
// libstdc++/102
|
||||||
|
void test02()
|
||||||
|
{
|
||||||
|
std::vector<int> v1;
|
||||||
|
std::vector<int> v2(v1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test02();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
// 1999-06-29 bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999-2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.1 vector constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// test range constructors and range-fill constructor
|
||||||
|
void
|
||||||
|
test03()
|
||||||
|
{
|
||||||
|
bool test = true;
|
||||||
|
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||||
|
const int B[] = {7, 7, 7, 7, 7};
|
||||||
|
const int N = sizeof(A) / sizeof(int);
|
||||||
|
const int M = sizeof(B) / sizeof(int);
|
||||||
|
|
||||||
|
std::vector<int> v3(A, A + N);
|
||||||
|
VERIFY(std::equal(v3.begin(), v3.end(), A));
|
||||||
|
|
||||||
|
std::vector<int> v4(v3.begin(), v3.end());
|
||||||
|
VERIFY(std::equal(v4.begin(), v4.end(), A));
|
||||||
|
|
||||||
|
std::vector<int> v5(M, 7);
|
||||||
|
VERIFY(std::equal(v5.begin(), v5.end(), B));
|
||||||
|
VERIFY(std::equal(B, B + M, v5.begin()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test03();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -31,62 +31,6 @@ using __gnu_test::tracker_alloc;
|
||||||
using __gnu_test::copy_constructor;
|
using __gnu_test::copy_constructor;
|
||||||
using __gnu_test::assignment_operator;
|
using __gnu_test::assignment_operator;
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct A { };
|
|
||||||
|
|
||||||
struct B { };
|
|
||||||
|
|
||||||
void test01()
|
|
||||||
{
|
|
||||||
// 1
|
|
||||||
std::vector< A<B> > vec01;
|
|
||||||
std::vector< A<B> > vec02(5);
|
|
||||||
typedef std::vector< A<B> >::size_type size_type;
|
|
||||||
|
|
||||||
vec01 = vec02;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2
|
|
||||||
template class std::vector<double>;
|
|
||||||
template class std::vector< A<B> >;
|
|
||||||
|
|
||||||
|
|
||||||
// libstdc++/102
|
|
||||||
void test02()
|
|
||||||
{
|
|
||||||
std::vector<int> v1;
|
|
||||||
std::vector<int> v2 (v1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// test range constructors and range-fill constructor
|
|
||||||
void
|
|
||||||
test03()
|
|
||||||
{
|
|
||||||
bool test = true;
|
|
||||||
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
|
|
||||||
const int B[] = {7, 7, 7, 7, 7};
|
|
||||||
const int N = sizeof(A) / sizeof(int);
|
|
||||||
const int M = sizeof(B) / sizeof(int);
|
|
||||||
|
|
||||||
std::vector<int> v3(A, A + N);
|
|
||||||
VERIFY(std::equal(v3.begin(), v3.end(), A));
|
|
||||||
|
|
||||||
std::vector<int> v4(v3.begin(), v3.end());
|
|
||||||
VERIFY(std::equal(v4.begin(), v4.end(), A));
|
|
||||||
|
|
||||||
std::vector<int> v5(M, 7);
|
|
||||||
VERIFY(std::equal(v5.begin(), v5.end(), B));
|
|
||||||
VERIFY(std::equal(B, B + M, v5.begin()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// libstdc++/6513
|
|
||||||
void test04()
|
|
||||||
{
|
|
||||||
const char* c_strings[5] = { "1", "2", "3", "4", "5" };
|
|
||||||
std::vector<std::string> strings(c_strings, c_strings + 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// @fn test_default_ctor_exception_gurantee This test verifies that if
|
// @fn test_default_ctor_exception_gurantee This test verifies that if
|
||||||
// one of the vector's contained objects throws an exception from its
|
// one of the vector's contained objects throws an exception from its
|
||||||
// constructor while the vector is being constructed and filled with
|
// constructor while the vector is being constructed and filled with
|
||||||
|
@ -625,10 +569,6 @@ test_range_assign_4_exception_guarantee()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
|
||||||
test02();
|
|
||||||
test03();
|
|
||||||
test04();
|
|
||||||
test_default_ctor_exception_gurantee();
|
test_default_ctor_exception_gurantee();
|
||||||
test_copy_ctor_exception_gurantee();
|
test_copy_ctor_exception_gurantee();
|
||||||
test_assignment_operator_1();
|
test_assignment_operator_1();
|
|
@ -0,0 +1,40 @@
|
||||||
|
// 1999-06-29 bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999-2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.1 vector constructors, copy, and assignment
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <testsuite_allocator.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
// libstdc++/6513
|
||||||
|
void test04()
|
||||||
|
{
|
||||||
|
const char* c_strings[5] = { "1", "2", "3", "4", "5" };
|
||||||
|
std::vector<std::string> strings(c_strings, c_strings + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test04();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
// 1999-11-09 bkoz
|
||||||
|
|
||||||
|
// Copyright (C) 1999, 2001 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 2, 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 COPYING. If not, write to the Free
|
||||||
|
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
// USA.
|
||||||
|
|
||||||
|
// 23.2.4.3 vector modifiers
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "testsuite_hooks.h"
|
||||||
|
|
||||||
|
bool test = true;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct A { };
|
||||||
|
|
||||||
|
struct B { };
|
||||||
|
|
||||||
|
// vector::insert(iterator, inputiterator first, inputiterator last)
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
// POD types
|
||||||
|
typedef std::vector<int> vec_POD;
|
||||||
|
vec_POD vec01;
|
||||||
|
int i01 = 5;
|
||||||
|
int* pi01 = &i01;
|
||||||
|
vec01.insert(vec01.begin(), pi01, pi01 + 1);
|
||||||
|
|
||||||
|
// non POD types
|
||||||
|
typedef std::vector< A<B> > vec_nonPOD;
|
||||||
|
vec_nonPOD vec02;
|
||||||
|
A<B> np01;
|
||||||
|
A<B>* pnp01 = &np01;
|
||||||
|
vec02.insert(vec02.begin(), pnp01, pnp01 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -25,30 +25,6 @@
|
||||||
|
|
||||||
bool test = true;
|
bool test = true;
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct A { };
|
|
||||||
|
|
||||||
struct B { };
|
|
||||||
|
|
||||||
// vector::insert(iterator, inputiterator first, inputiterator last)
|
|
||||||
void
|
|
||||||
test01()
|
|
||||||
{
|
|
||||||
// POD types
|
|
||||||
typedef std::vector<int> vec_POD;
|
|
||||||
vec_POD vec01;
|
|
||||||
int i01 = 5;
|
|
||||||
int* pi01 = &i01;
|
|
||||||
vec01.insert(vec01.begin(), pi01, pi01 + 1);
|
|
||||||
|
|
||||||
// non POD types
|
|
||||||
typedef std::vector< A<B> > vec_nonPOD;
|
|
||||||
vec_nonPOD vec02;
|
|
||||||
A<B> np01;
|
|
||||||
A<B>* pnp01 = &np01;
|
|
||||||
vec02.insert(vec02.begin(), pnp01, pnp01 + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// test the assign() function
|
// test the assign() function
|
||||||
void
|
void
|
||||||
test03()
|
test03()
|
||||||
|
@ -81,8 +57,6 @@ test03()
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test01();
|
|
||||||
test03();
|
test03();
|
||||||
|
return 0;
|
||||||
return !test;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue