693 EXPECT_GE(list->capacity, list->size); |
706 EXPECT_GE(list->capacity, list->size); |
694 EXPECT_EQ(*(int *) cxListAt(list, 0), testdata.data[1]); |
707 EXPECT_EQ(*(int *) cxListAt(list, 0), testdata.data[1]); |
695 EXPECT_EQ(*(int *) cxListAt(list, 1), testdata.data[3]); |
708 EXPECT_EQ(*(int *) cxListAt(list, 1), testdata.data[3]); |
696 |
709 |
697 EXPECT_NE(cxListRemove(list, testdata_len), 0); |
710 EXPECT_NE(cxListRemove(list, testdata_len), 0); |
|
711 } |
|
712 |
|
713 void verifyClear(CxList *list) { |
|
714 // use the testing allocator for testing the destructor function |
|
715 list->content_destructor_type = CX_DESTRUCTOR_ADVANCED; |
|
716 list->advanced_destructor.func = free_testdatastruct; |
|
717 list->advanced_destructor.data = &testingAllocator; |
|
718 |
|
719 testdatastruct s[10]; |
|
720 for (auto &t: s) { |
|
721 t.ptr = cxMalloc(&testingAllocator, 16); |
|
722 cxListAdd(list, &t); |
|
723 } |
|
724 |
|
725 cxListClear(list); |
698 } |
726 } |
699 |
727 |
700 static void verifySwap(CxList *list) { |
728 static void verifySwap(CxList *list) { |
701 ASSERT_EQ(list->size, 0); |
729 ASSERT_EQ(list->size, 0); |
702 |
730 |
995 |
1023 |
996 TEST_F(ArrayList, cxListRemove) { |
1024 TEST_F(ArrayList, cxListRemove) { |
997 verifyRemove(arrayListFromTestData()); |
1025 verifyRemove(arrayListFromTestData()); |
998 } |
1026 } |
999 |
1027 |
|
1028 TEST_F(LinkedList, cxListClear) { |
|
1029 verifyClear(autofree(cxLinkedListCreateSimple(sizeof(testdatastruct)))); |
|
1030 } |
|
1031 |
|
1032 TEST_F(PointerLinkedList, cxListClear) { |
|
1033 auto l = cxLinkedListCreateSimple(sizeof(testdatastruct)); |
|
1034 cxListStorePointers(l); |
|
1035 verifyClear(autofree(l)); |
|
1036 } |
|
1037 |
|
1038 TEST_F(ArrayList, cxListClear) { |
|
1039 verifyClear(autofree(cxArrayListCreateSimple(sizeof(testdatastruct), 8))); |
|
1040 } |
|
1041 |
1000 TEST_F(LinkedList, cxListSwap) { |
1042 TEST_F(LinkedList, cxListSwap) { |
1001 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
1043 verifySwap(autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int)))); |
1002 } |
1044 } |
1003 |
1045 |
1004 TEST_F(PointerLinkedList, cxListSwap) { |
1046 TEST_F(PointerLinkedList, cxListSwap) { |