1.1 --- a/test/test_list.cpp Sun Nov 20 21:08:36 2022 +0100 1.2 +++ b/test/test_list.cpp Wed Nov 23 22:40:55 2022 +0100 1.3 @@ -569,28 +569,21 @@ 1.4 } 1.5 1.6 auto linkedListFromTestData() const -> CxList * { 1.7 - // TODO: replace with cxListAddArray 1.8 - return autofree( 1.9 - cxLinkedListFromArray( 1.10 - &testingAllocator, 1.11 - cx_cmp_int, 1.12 - sizeof(int), 1.13 - testdata_len, 1.14 - testdata.data.data() 1.15 - ) 1.16 - ); 1.17 + auto list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); 1.18 + cxListAddArray(list, testdata.data.data(), testdata_len); 1.19 + return list; 1.20 } 1.21 1.22 auto pointerLinkedListFromTestData() const -> CxList * { 1.23 auto list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int)); 1.24 + // note: cannot use cxListAddArray() because we don't have a list of pointers 1.25 cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]); 1.26 return list; 1.27 } 1.28 1.29 auto arrayListFromTestData() const -> CxList * { 1.30 auto list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), testdata_len)); 1.31 - // TODO: replace with cxListAddArray 1.32 - cx_for_n(i, testdata_len) cxListAdd(list, &testdata.data[i]); 1.33 + cxListAddArray(list, testdata.data.data(), testdata_len); 1.34 return list; 1.35 } 1.36 1.37 @@ -796,18 +789,6 @@ 1.38 verifyCreate(list); 1.39 } 1.40 1.41 -TEST_F(LinkedList, cxLinkedListFromArray) { 1.42 - CxList *expected = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); 1.43 - cx_for_n (i, testdata_len) cxListAdd(expected, &testdata.data[i]); 1.44 - CxList *list = autofree(cxLinkedListFromArray(&testingAllocator, cx_cmp_int, sizeof(int), 1.45 - testdata_len, testdata.data.data())); 1.46 - ASSERT_NE(list, nullptr); 1.47 - EXPECT_EQ(list->itemsize, sizeof(int)); 1.48 - EXPECT_EQ(list->capacity, (size_t) -1); 1.49 - EXPECT_EQ(list->size, testdata_len); 1.50 - EXPECT_EQ(cxListCompare(list, expected), 0); 1.51 -} 1.52 - 1.53 TEST_F(ArrayList, cxArrayListCreate) { 1.54 CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 8)); 1.55 ASSERT_NE(list, nullptr); 1.56 @@ -905,13 +886,15 @@ 1.57 1.58 TEST_F(LinkedList, InsertViaIterator) { 1.59 int fivenums[] = {0, 1, 2, 3, 4, 5}; 1.60 - CxList *list = autofree(cxLinkedListFromArray(&testingAllocator, cx_cmp_int, sizeof(int), 5, fivenums)); 1.61 + CxList *list = autofree(cxLinkedListCreate(&testingAllocator, cx_cmp_int, sizeof(int))); 1.62 + cxListAddArray(list, fivenums, 5); 1.63 verifyInsertViaIterator(list); 1.64 } 1.65 1.66 TEST_F(PointerLinkedList, InsertViaIterator) { 1.67 int fivenums[] = {0, 1, 2, 3, 4, 5}; 1.68 CxList *list = autofree(cxPointerLinkedListCreate(&testingAllocator, cx_cmp_int)); 1.69 + // note: don't use cxListAddArray() here, because we don't have a list of pointers 1.70 cx_for_n (i, 5) cxListAdd(list, &fivenums[i]); 1.71 verifyInsertViaIterator(list); 1.72 } 1.73 @@ -919,8 +902,7 @@ 1.74 TEST_F(ArrayList, InsertViaIterator) { 1.75 int fivenums[] = {0, 1, 2, 3, 4, 5}; 1.76 CxList *list = autofree(cxArrayListCreate(&testingAllocator, cx_cmp_int, sizeof(int), 4)); 1.77 - // TODO: replace with cxListAddArray 1.78 - cx_for_n (i, 5) cxListAdd(list, &fivenums[i]); 1.79 + cxListAddArray(list, fivenums, 5); 1.80 verifyInsertViaIterator(list); 1.81 } 1.82