]> git.mdlowis.com Git - projs/libcds.git/commitdiff
+test for release on failed insert
authora bellenir <a@bellenir.com>
Thu, 21 Aug 2014 08:50:58 +0000 (08:50 +0000)
committera bellenir <a@bellenir.com>
Thu, 21 Aug 2014 08:50:58 +0000 (08:50 +0000)
tests/test_list.c

index 7c03dd06076ef23e37b851121957b8c20a927d9c..8284bf18a81bf4092b819124f6378d344b2f80f7 100644 (file)
@@ -512,6 +512,17 @@ TEST_SUITE(List) {
         CHECK( node == NULL );
         mem_release(list);
     }
+    TEST(Verify_insert_releases_if_index_out_of_bounds)
+    {
+        list_t* list = list_new();
+        void* box88 = mem_box(88);
+        list_push_back(list, mem_box(0x1234));
+        mem_retain(box88);
+        list_insert(list, 8, box88);
+        CHECK(1 == mem_num_references(box88))
+        mem_release(list);
+        mem_release(box88);
+    }
 
     //-------------------------------------------------------------------------
     // Test list_insert_after function