From f7a4ec3244ab2754b9953496358d31f567df2288 Mon Sep 17 00:00:00 2001 From: jhoffert Date: Thu, 10 Jan 2008 15:56:38 +0000 Subject: Fixed use of bracket operator with iterator. The number in the bracket is additive - not absolute. --- TAO/tests/Sequence_Iterators/StringSeq.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TAO/tests/Sequence_Iterators/StringSeq.cpp b/TAO/tests/Sequence_Iterators/StringSeq.cpp index 4441737011d..965a2b4e728 100644 --- a/TAO/tests/Sequence_Iterators/StringSeq.cpp +++ b/TAO/tests/Sequence_Iterators/StringSeq.cpp @@ -127,8 +127,13 @@ int test_sequence () FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[2]) != 0); // test operator[] write - a_it[0] = CORBA::string_dup (elem0_cstr); - FAIL_RETURN_IF (ACE_OS::strcmp (a[1],elem0_cstr) != 0); + // NOTE: This assignment actually modifies the third element + // in the sequence since the iterator was previously positioned + // at the third element. I believe these are the proper semantics + // for using the bracket operator with an iterator. The number + // in the brackets is additive - not absolute. + a_it[0] = CORBA::string_dup (elem2_cstr); + FAIL_RETURN_IF (ACE_OS::strcmp (a[2], elem2_cstr) != 0); // reset content of sequence a a[1] = CORBA::string_dup (elem1_cstr); @@ -149,7 +154,6 @@ int test_sequence () // Memory is leaked here from // TAO::details::string_traits_base::default_initializer() - std::copy (a.begin (), a.end (), test.begin ()); @@ -165,13 +169,15 @@ int test_sequence () } /// Testing - using ostream_iterator - std::ostringstream ostream; std::copy (a.begin (), a.end (), std::ostream_iterator (ostream, "\n")); + // The third sequence element has been modified. Either we need to restore + // the original sequence values or modify the test here. I modified the + // test since it's easier. FAIL_RETURN_IF ( ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); -- cgit v1.2.1