diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2007-11-21 21:44:29 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2007-11-21 21:44:29 +0000 |
commit | 04bb91a5d04dd8cbbc3233ccd66dc785606fa135 (patch) | |
tree | d657414420f6e77bf9a84d70f86a4d0887dbe194 /ACE/tests/Vector_Test.cpp | |
parent | c4ce94c336af5e15a03eee89fcb0c726f52f08ba (diff) | |
download | ATCD-04bb91a5d04dd8cbbc3233ccd66dc785606fa135.tar.gz |
ChangeLogTag:Wed
Diffstat (limited to 'ACE/tests/Vector_Test.cpp')
-rw-r--r-- | ACE/tests/Vector_Test.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/ACE/tests/Vector_Test.cpp b/ACE/tests/Vector_Test.cpp index 1d0933d73eb..3866094c62b 100644 --- a/ACE/tests/Vector_Test.cpp +++ b/ACE/tests/Vector_Test.cpp @@ -12,7 +12,8 @@ // This is a simple test of the ACE_Vector class and its iterators. // // = AUTHOR -// Gonzalo A. Diethelm <gonzalo.diethelm@aditiva.com> +// Gonzalo A. Diethelm <gonzalo.diethelm@aditiva.com> and +// Karl-Heinz Wind <wind@itq.de> // // ============================================================================ @@ -37,6 +38,9 @@ const size_t TOP = 100; const size_t LEFT = 10; const size_t RESIZE = 20; +const size_t FILLER1 = 1; +const size_t FILLER2 = 2; + int run_main (int, ACE_TCHAR *[]) { ACE_START_TEST (ACE_TEXT ("Vector_Test")); @@ -107,8 +111,8 @@ int run_main (int, ACE_TCHAR *[]) ACE_ASSERT (vector[i] == 0); } ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("vector[%d]:%d\n"), - i, vector[i])); + ACE_TEXT ("vector[%d]:%d\n"), + i, vector[i])); } vector.clear (); @@ -117,6 +121,37 @@ int run_main (int, ACE_TCHAR *[]) ACE_TEXT ("Size: %d\n"), vector.size ())); + // test resize (shrink and enlarge with buffer realloc) + VECTOR vector2; + + // should be around 32 + size_t boundary = vector2.capacity (); + + // we fill everything up with 1 + // 1, 1, 1, 1, 1, 1, 1, 1, + // 1, 1, 1, 1, 1, 1, 1, 1, + // 1, 1, 1, 1, 1, 1, 1, 1, + // 1, 1, 1, 1, 1, 1, 1, 1, + for (i = 0; i < boundary; ++i) + vector2.push_back (FILLER1); + + // we throw almost everything away. + vector2.resize (1, 0); + + // we fill up with another pattern + // 1, 2, 2, 2, 2, 2, 2, 2, + // 2, 2, 2, 2, 2, 2, 2, 2, + // 2, 2, 2, 2, 2, 2, 2, 2, + // 2, 2, 2, 2, 2, 2, 2, 2, + // 2, + for (i = 0; i < boundary; ++i) + vector2.push_back (FILLER2); + + // now we check the result + ACE_ASSERT (vector2[0] == FILLER1); + for (i = 0; i < boundary; ++i) + ACE_ASSERT (vector2[i+1] == FILLER2); + VECTOR v1; VECTOR v2; v1.push_back (1); @@ -141,3 +176,4 @@ int run_main (int, ACE_TCHAR *[]) return 0; } + |