diff options
Diffstat (limited to 'TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp')
-rw-r--r-- | TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp index ed9ff002b0f..076911167b3 100644 --- a/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp +++ b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp @@ -42,7 +42,7 @@ int test_sequence () // test for correct behaviour for empty sequence FAIL_RETURN_IF (a.begin() != a.end ()); - + mock_reference* elem0 = mock_reference::allocate (0); mock_reference* elem1 = mock_reference::allocate (1); mock_reference* elem2 = mock_reference::allocate (2); @@ -50,10 +50,18 @@ int test_sequence () // setup of an example sequence a.length (4); + /* + * JWH2 - I don't think _duplicate is needed. Memory leaks show + * up when it's used. a[0] = mock_reference::_duplicate (elem0); a[1] = mock_reference::_duplicate (elem1); a[2] = mock_reference::_duplicate (elem2); a[3] = mock_reference::_duplicate (elem3); + */ + a[0] = elem0; + a[1] = elem1; + a[2] = elem2; + a[3] = elem3; // test iterator copy constructor ITERATOR_T a_it (a.begin ()); @@ -161,7 +169,8 @@ int test_sequence () } /// Testing - using ostream_iterator - + /// JWH2 - I don't think the ostream test makes sense for object references. + /* std::ostringstream ostream; std::copy (a.begin (), a.end (), @@ -170,6 +179,7 @@ int test_sequence () FAIL_RETURN_IF ( ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + */ return 0; } @@ -189,11 +199,23 @@ int test_const_sequence () mock_reference* elem3 = mock_reference::allocate (3); // setup of an example sequence + /* + * JWH2 - I don't think _duplicate is needed. Memory leaks show + * up when it's used. setup[0] = mock_reference::_duplicate (elem0); setup[1] = mock_reference::_duplicate (elem1); setup[2] = mock_reference::_duplicate (elem2); setup[3] = mock_reference::_duplicate (elem3); - + */ + setup[0] = elem0; + setup[1] = elem1; + setup[2] = elem2; + setup[3] = elem3; + + // JWH2 - I think the double delete problem is here. Shouldn't the + // underlying assignment operator make sure memory is allocated as + // needed? It seems this isn't happening at some level since valgrind + // is complaining that the sequence dtor is being called twice. const tested_sequence a = setup; // test equality operator @@ -308,7 +330,8 @@ int test_const_sequence () } /// Testing - using ostream_iterator - + /// JWH2 - I don't think the ostream test makes sense for object references. + /* std::ostringstream ostream; std::copy (a.begin (), a.end (), @@ -317,6 +340,7 @@ int test_const_sequence () FAIL_RETURN_IF ( ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + */ return 0; } @@ -348,10 +372,18 @@ int test_sequence_reverse () // setup of an example sequence a.length (4); + /* + * JWH2 - I don't think _duplicate is needed. Memory leaks show + * up when it's used. a[0] = mock_reference::_duplicate (elem0); a[1] = mock_reference::_duplicate (elem1); a[2] = mock_reference::_duplicate (elem2); a[3] = mock_reference::_duplicate (elem3); + */ + a[0] = elem0; + a[1] = elem1; + a[2] = elem2; + a[3] = elem3; // test iterator copy constructor REVERSE_ITERATOR_T a_it (a.rbegin ()); @@ -459,7 +491,8 @@ int test_sequence_reverse () } /// Testing - using ostream_iterator - + /// JWH2 - I don't think the ostream test makes sense for object references. + /* std::ostringstream ostream; std::copy (a.rbegin (), a.rend (), @@ -468,6 +501,7 @@ int test_sequence_reverse () FAIL_RETURN_IF ( ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + */ return 0; } @@ -487,11 +521,23 @@ int test_const_sequence_reverse () mock_reference* elem3 = mock_reference::allocate (3); // setup of an example sequence + /* + * JWH2 - I don't think _duplicate is needed. Memory leaks show + * up when it's used. setup[0] = mock_reference::_duplicate (elem0); setup[1] = mock_reference::_duplicate (elem1); setup[2] = mock_reference::_duplicate (elem2); setup[3] = mock_reference::_duplicate (elem3); - + */ + setup[0] = elem0; + setup[1] = elem1; + setup[2] = elem2; + setup[3] = elem3; + + // JWH2 - I think the double delete problem is here. Shouldn't the + // underlying assignment operator make sure memory is allocated as + // needed? It seems this isn't happening at some level since valgrind + // is complaining that the sequence dtor is being called twice. const tested_sequence a = setup; // test equality operator @@ -615,7 +661,8 @@ int test_const_sequence_reverse () } /// Testing - using ostream_iterator - + /// JWH2 - I don't think the ostream test makes sense for object references. + /* std::ostringstream ostream; std::copy (a.rbegin (), a.rend (), @@ -624,6 +671,7 @@ int test_const_sequence_reverse () FAIL_RETURN_IF ( ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + */ return 0; } @@ -641,6 +689,8 @@ int main(int,char*[]) status += test_sequence< tested_sequence::const_iterator> (); // Test Const_Generic_Sequence_Iterator with const sequence. + // JWH2 - This test is causing a segmentation fault - a double delete of the + // sequence (and the elements in it). I'm not sure why. status += test_const_sequence< tested_sequence::const_iterator> (); // Test Generic_Sequence_Reverse_Iterator. @@ -650,6 +700,8 @@ int main(int,char*[]) status += test_sequence_reverse< tested_sequence::const_reverse_iterator> (); // Test Const_Generic_Sequence_Reverse_Iterator with const sequence. + // JWH2 - This test is causing a segmentation fault - a double delete of the + // sequence (and the elements in it). I'm not sure why. status += test_const_sequence_reverse< tested_sequence::const_reverse_iterator> (); return status; |