]> git.saurik.com Git - wxWidgets.git/commitdiff
fix the bug in insert(end(), value) and added unit test for it
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Oct 2008 09:04:52 +0000 (09:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Oct 2008 09:04:52 +0000 (09:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/list.h
tests/lists/lists.cpp

index aca713b04c0f0e9f3c8bfa04b9f011f4ab7ff388..a93d2eca931a2ebdd600a46c5ce0ea9093688bab 100644 (file)
@@ -1007,7 +1007,10 @@ private:
         }                                                                   \
         iterator insert(const iterator& it, const_reference v)              \
         {                                                                   \
-            Insert(it.m_node, (const_base_reference)v);                     \
+            if ( it == end() )                                              \
+                Append((const_base_reference)v);                            \
+            else                                                            \
+                Insert(it.m_node, (const_base_reference)v);                 \
             iterator itprev(it);                                            \
             return itprev--;                                                \
         }                                                                   \
@@ -1017,7 +1020,7 @@ private:
                 Insert(it.m_node, (const_base_reference)v);                 \
         }                                                                   \
         void insert(const iterator& it,                                     \
-                    const const_iterator& first, const const_iterator& last)\
+                    const_iterator first, const const_iterator& last)       \
         {                                                                   \
             for(; first != last; ++first)                                   \
                 Insert(it.m_node, (const_base_reference)*first);            \
index 85eea4c98f7cb73895c4014b0e3918862019ebc7..ac9964549042d6b1ad52341c82edcf798bba58e2 100644 (file)
@@ -157,6 +157,14 @@ void ListsTestCase::wxStdListTest()
     {
         CPPUNIT_ASSERT( *it == i + &i );
     }
+
+    list1.clear();
+    CPPUNIT_ASSERT( list1.empty() );
+
+    list1.insert(list1.end(), (int *)1);
+    list1.insert(list1.end(), (int *)2);
+    CPPUNIT_ASSERT_EQUAL( (int *)1, list1.front() );
+    CPPUNIT_ASSERT_EQUAL( (int *)2, list1.back() );
 }
 
 void ListsTestCase::wxListCtorTest()