diff options
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/vector_capacity.cc')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/vector_capacity.cc | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector_capacity.cc b/libstdc++-v3/testsuite/23_containers/vector_capacity.cc index 621ef7e373f..b6e347de309 100644 --- a/libstdc++-v3/testsuite/23_containers/vector_capacity.cc +++ b/libstdc++-v3/testsuite/23_containers/vector_capacity.cc @@ -1,7 +1,7 @@ // 1999-05-07 // bkoz -// Copyright (C) 1999, 2002 Free Software Foundation, Inc. +// 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 @@ -26,6 +26,13 @@ #include <testsuite_allocator.h> #include <testsuite_hooks.h> +using __gnu_cxx_test::copy_tracker; +using __gnu_cxx_test::allocation_tracker; +using __gnu_cxx_test::tracker_alloc; +using __gnu_cxx_test::copy_constructor; +using __gnu_cxx_test::assignment_operator; +using __gnu_cxx_test::destructor; + template<typename T> struct A { }; @@ -58,7 +65,6 @@ void test01() void test02() { bool test = true; - { std::vector<int> array; const std::size_t size = array.max_size(); @@ -100,34 +106,15 @@ void test02() } } -void test03() -{ - bool test = true; - std::vector<int> v; - try - { - v.resize(v.max_size()); - v[v.max_size() - 1] = 2002; - } - catch (const std::bad_alloc& error) - { - test = true; - } - catch (...) - { - test = false; - } - VERIFY( test ); -} - // Verifies basic functionality of reserve() with forced reallocation. void test_reserve() { - typedef gnu_copy_tracker T; - typedef std::vector<T, gnu_new_allocator<T> > X; + bool test = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_alloc<T> > X; - gnu_allocator_tracker::resetCounts(); + allocation_tracker::resetCounts(); { X a(3); const X::size_type old_size = a.size(); @@ -141,11 +128,11 @@ test_reserve() VERIFY(new_capacity <= a.capacity()); // [23.2.4.1 (3)] VERIFY(old_size == a.size()); - VERIFY(gnu_copy_constructor::count() <= old_size); - VERIFY(gnu_destructor::count() <= old_size); + VERIFY(copy_constructor::count() <= old_size); + VERIFY(destructor::count() <= old_size); } // check for memory leaks - VERIFY(gnu_allocator_tracker::allocationTotal() == gnu_allocator_tracker::deallocationTotal()); + VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); } // Verifies that reserve() with reallocation offers the strong @@ -153,17 +140,18 @@ test_reserve() void test_reserve_exception_guarantee() { - typedef gnu_copy_tracker T; - typedef std::vector<T, gnu_new_allocator<T> > X; + bool test = true; + typedef copy_tracker T; + typedef std::vector<T, tracker_alloc<T> > X; - gnu_allocator_tracker::resetCounts(); + allocation_tracker::resetCounts(); { X a(7); const X::size_type old_size = a.size(); const X::size_type old_capacity = a.capacity(); const X::size_type new_capacity = old_capacity + 10; T::reset(); - gnu_copy_constructor::throw_on(3); + copy_constructor::throw_on(3); try { @@ -175,16 +163,15 @@ test_reserve_exception_guarantee() } VERIFY(old_capacity == a.capacity()); - VERIFY(gnu_copy_constructor::count() == gnu_destructor::count()+1); + VERIFY(copy_constructor::count() == destructor::count()+1); } - VERIFY(gnu_allocator_tracker::allocationTotal() == gnu_allocator_tracker::deallocationTotal()); + VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal()); } int main() { test01(); test02(); - test03(); test_reserve(); test_reserve_exception_guarantee(); return 0; |