iterator validity insert test

[SVN r2788]
This commit is contained in:
Jan Gaspar
2005-12-22 23:16:58 +00:00
parent 32bfbced60
commit 1e3f147177
7 changed files with 46 additions and 25 deletions

View File

@@ -12,6 +12,8 @@
#include "test.hpp"
int array[] = { 1, 2, 3, 4, 5 };
// test of the example (introduced in the documentation)
void validity_example_test() {
@@ -32,15 +34,32 @@ void validity_example_test() {
void validity_insert_test() {
circular_buffer<int> cb1(4);
cb1.push_back(1);
cb1.push_back(2);
cb1.push_back(3);
cb1.push_back(4);
circular_buffer<int>::iterator it1 = cb1.begin();
circular_buffer<int> cb(4, array, array + 3);
circular_buffer<int>::iterator it1 = cb.begin();
circular_buffer<int>::iterator it2 = cb.begin() + 1;
circular_buffer<int>::iterator it3 = cb.begin() + 2;
// cb = {1, 2, 3}
BOOST_CHECK(*it1 == 1);
cb1.insert(cb1.begin() + 1, 5);
BOOST_CHECK(*it1 == 4);
BOOST_CHECK(*it2 == 2);
BOOST_CHECK(*it3 == 3);
cb.insert(cb.begin() + 1, 4);
// cb = {1, 4, 2, 3}
BOOST_CHECK(*it1 == 1);
BOOST_CHECK(*it2 == 4);
BOOST_CHECK(*it3 == 2);
cb.insert(cb.begin() + 1, 5);
// cb = {3, 5, 4, 2}
BOOST_CHECK(*it1 == 3);
BOOST_CHECK(*it2 == 5);
BOOST_CHECK(*it3 == 4);
}
void validity_insert_n_test() {
circular_buffer<int> cb2(4);
cb2.push_back(1);
@@ -53,20 +72,18 @@ void validity_insert_test() {
BOOST_CHECK(*it2 == 4);
}
void validity_test() {
// erase
// rerase
// insert
// rinsert
// push_back
// push_front
// linearize
// swap
// set_capacity
// rset_capacity
// resize
// rresize
}
// erase
// rerase
// insert
// rinsert
// push_back
// push_front
// linearize
// swap
// set_capacity
// rset_capacity
// resize
// rresize
// test main
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
@@ -75,6 +92,7 @@ test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
tests->add(BOOST_TEST_CASE(&validity_example_test));
tests->add(BOOST_TEST_CASE(&validity_insert_test));
tests->add(BOOST_TEST_CASE(&validity_insert_n_test));
return tests;
}