diff -r 1e2be40f0cb5 -r 6c81ee4f11ad test/test_list.cpp --- a/test/test_list.cpp Sun Nov 20 21:08:36 2022 +0100 +++ b/test/test_list.cpp Wed Nov 23 22:40:55 2022 +0100 @@ -569,28 +569,21 @@ } auto linkedListFromTestData() const -> CxList * { - // TODO: replace with cxListAddArray - return autofree( - cxLinkedListFromArray( - &testingAllocator, - cx_cmp_int, - sizeof(int), - testdata_len, - testdata.data.data() - ) - ); + auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); + cxListAddArray(list, testdata.data.data(), testdata_len); + return list; } auto pointerLinkedListFromTestData() const -> CxList * { auto list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int)); + // note: cannot use cxListAddArray() because we don't have a list of pointers cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]); return list; } auto arrayListFromTestData() const -> CxList * { auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), testdata_len)); - // TODO: replace with cxListAddArray - cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]); + cxListAddArray(list, testdata.data.data(), testdata_len); return list; } @@ -796,18 +789,6 @@ verifyCreate(list); } -TEST_F(LinkedList, cxLinkedListFromArray) { - CxList *expected = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); - cx_for_n (i, testdata_len) cxListAdd(expected, &testdata.data[i]); - CxList *list = autofree(cxLinkedListFromArray(&testingAllocator, cx_cmp_int, sizeof(int), - testdata_len, testdata.data.data())); - ASSERT_NE(list, nullptr); - EXPECT_EQ(list->itemsize, sizeof(int)); - EXPECT_EQ(list->capacity, (size_t) -1); - EXPECT_EQ(list->size, testdata_len); - EXPECT_EQ(cxListCompare(list, expected), 0); -} - TEST_F(ArrayList, cxArrayListCreate) { CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8)); ASSERT_NE(list, nullptr); @@ -905,13 +886,15 @@ TEST_F(LinkedList, InsertViaIterator) { int fivenums[] = {0, 1, 2, 3, 4, 5}; - CxList *list = autofree(cxLinkedListFromArray(&testingAllocator, cx_cmp_int, sizeof(int), 5, fivenums)); + CxList *list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); + cxListAddArray(list, fivenums, 5); verifyInsertViaIterator(list); } TEST_F(PointerLinkedList, InsertViaIterator) { int fivenums[] = {0, 1, 2, 3, 4, 5}; CxList *list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int)); + // note: don't use cxListAddArray() here, because we don't have a list of pointers cx_for_n (i, 5) cxListAdd(list, &fivenums[i]); verifyInsertViaIterator(list); } @@ -919,8 +902,7 @@ TEST_F(ArrayList, InsertViaIterator) { int fivenums[] = {0, 1, 2, 3, 4, 5}; CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4)); - // TODO: replace with cxListAddArray - cx_for_n (i, 5) cxListAdd(list, &fivenums[i]); + cxListAddArray(list, fivenums, 5); verifyInsertViaIterator(list); }