iterator insert(const iterator& it, const_reference v) \
{ \
if ( it == end() ) \
+ { \
Append((const_base_reference)v); \
+ /* \
+ note that this is the new end(), the old one was \
+ invalidated by the Append() call, and this is why we \
+ can't use the same code as in the normal case below \
+ */ \
+ iterator itins(end()); \
+ return --itins; \
+ } \
else \
+ { \
Insert(it.m_node, (const_base_reference)v); \
- iterator itprev(it); \
- return itprev--; \
+ iterator itins(it); \
+ return --itins; \
+ } \
} \
void insert(const iterator& it, size_type n, const_reference v) \
{ \
list1.clear();
CPPUNIT_ASSERT( list1.empty() );
- list1.insert(list1.end(), (int *)1);
- list1.insert(list1.end(), (int *)2);
+ it = list1.insert(list1.end(), (int *)1);
+ CPPUNIT_ASSERT_EQUAL( (int *)1, *it );
+ CPPUNIT_ASSERT( it == list1.begin() );
CPPUNIT_ASSERT_EQUAL( (int *)1, list1.front() );
+
+ it = list1.insert(list1.end(), (int *)2);
+ CPPUNIT_ASSERT_EQUAL( (int *)2, *it );
+ CPPUNIT_ASSERT( ++it == list1.end() );
CPPUNIT_ASSERT_EQUAL( (int *)2, list1.back() );
+ it = list1.begin();
+ wxListInt::iterator it2 = list1.insert(++it, (int *)3);
+ CPPUNIT_ASSERT_EQUAL( (int *)3, *it2 );
+
it = list1.begin();
it = list1.erase(++it, list1.end());
CPPUNIT_ASSERT_EQUAL( 1, list1.size() );