| 1475 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == testdata[3]); |
1475 CX_TEST_ASSERT(*(int *) cxListAt(list, 1) == testdata[3]); |
| 1476 CX_TEST_ASSERT(cxListRemove(list, testdata_len) != 0); |
1476 CX_TEST_ASSERT(cxListRemove(list, testdata_len) != 0); |
| 1477 free(testdata); |
1477 free(testdata); |
| 1478 }) |
1478 }) |
| 1479 |
1479 |
| |
1480 roll_out_test_combos(remove_and_get, { |
| |
1481 int testdata[10]; |
| |
1482 for (unsigned i = 0 ; i < 10 ; i++) { |
| |
1483 testdata[i] = 2*i; |
| |
1484 cxListAdd(list, &testdata[i]); |
| |
1485 } |
| |
1486 if (isptrlist) { |
| |
1487 int *x; |
| |
1488 CX_TEST_ASSERT(cxListPop(list, &x) == 0); |
| |
1489 CX_TEST_ASSERT(*x == 18); |
| |
1490 CX_TEST_ASSERT(cxListPop(list, &x) == 0); |
| |
1491 CX_TEST_ASSERT(*x == 16); |
| |
1492 CX_TEST_ASSERT(cxListPopFront(list, &x) == 0); |
| |
1493 CX_TEST_ASSERT(*x == 0); |
| |
1494 CX_TEST_ASSERT(cxListPopFront(list, &x) == 0); |
| |
1495 CX_TEST_ASSERT(*x == 2); |
| |
1496 CX_TEST_ASSERT(cxListRemoveAndGet(list, 3, &x) == 0); |
| |
1497 CX_TEST_ASSERT(*x == 10); |
| |
1498 CX_TEST_ASSERT(cxListRemoveAndGet(list, 3, &x) == 0); |
| |
1499 CX_TEST_ASSERT(*x == 12); |
| |
1500 CX_TEST_ASSERT(cxListRemoveAndGet(list, 8, &x) != 0); |
| |
1501 CX_TEST_ASSERT(*x == 12); |
| |
1502 |
| |
1503 *x = 1337; |
| |
1504 cxListClear(list); |
| |
1505 CX_TEST_ASSERT(cxListRemoveAndGet(list, 0, &x) != 0); |
| |
1506 CX_TEST_ASSERT(cxListRemoveAndGet(list, 1, &x) != 0); |
| |
1507 CX_TEST_ASSERT(cxListPop(list, &x) != 0); |
| |
1508 CX_TEST_ASSERT(cxListPopFront(list, &x) != 0); |
| |
1509 CX_TEST_ASSERT(*x == 1337); |
| |
1510 } else { |
| |
1511 int x; |
| |
1512 CX_TEST_ASSERT(cxListPop(list, &x) == 0); |
| |
1513 CX_TEST_ASSERT(x == 18); |
| |
1514 CX_TEST_ASSERT(cxListPop(list, &x) == 0); |
| |
1515 CX_TEST_ASSERT(x == 16); |
| |
1516 CX_TEST_ASSERT(cxListPopFront(list, &x) == 0); |
| |
1517 CX_TEST_ASSERT(x == 0); |
| |
1518 CX_TEST_ASSERT(cxListPopFront(list, &x) == 0); |
| |
1519 CX_TEST_ASSERT(x == 2); |
| |
1520 CX_TEST_ASSERT(cxListRemoveAndGet(list, 3, &x) == 0); |
| |
1521 CX_TEST_ASSERT(x == 10); |
| |
1522 CX_TEST_ASSERT(cxListRemoveAndGet(list, 3, &x) == 0); |
| |
1523 CX_TEST_ASSERT(x == 12); |
| |
1524 CX_TEST_ASSERT(cxListRemoveAndGet(list, 8, &x) != 0); |
| |
1525 CX_TEST_ASSERT(x == 12); |
| |
1526 |
| |
1527 x = 1337; |
| |
1528 cxListClear(list); |
| |
1529 CX_TEST_ASSERT(cxListRemoveAndGet(list, 0, &x) != 0); |
| |
1530 CX_TEST_ASSERT(cxListRemoveAndGet(list, 1, &x) != 0); |
| |
1531 CX_TEST_ASSERT(cxListPop(list, &x) != 0); |
| |
1532 CX_TEST_ASSERT(cxListPopFront(list, &x) != 0); |
| |
1533 CX_TEST_ASSERT(x == 1337); |
| |
1534 } |
| |
1535 }) |
| |
1536 |
| 1480 static unsigned test_remove_array_destr_ctr; |
1537 static unsigned test_remove_array_destr_ctr; |
| 1481 static void test_remove_array_destr(cx_attr_unused void *d) { |
1538 static void test_remove_array_destr(cx_attr_unused void *d) { |
| 1482 test_remove_array_destr_ctr++; |
1539 test_remove_array_destr_ctr++; |
| 1483 } |
1540 } |
| 1484 |
1541 |
| 1656 cxListAdd(list, &v3); |
1713 cxListAdd(list, &v3); |
| 1657 |
1714 |
| 1658 // Change the first element |
1715 // Change the first element |
| 1659 int v1new = 99; |
1716 int v1new = 99; |
| 1660 CX_TEST_ASSERT(cxListSet(list, 0, &v1new) == 0); |
1717 CX_TEST_ASSERT(cxListSet(list, 0, &v1new) == 0); |
| 1661 CX_TEST_ASSERT(*(int *) cxListAt(list, 0) == 99); |
1718 CX_TEST_ASSERT(*(int *) cxListFirst(list) == 99); |
| 1662 |
1719 |
| 1663 // Change the last element |
1720 // Change the last element |
| 1664 int v3new = 101; |
1721 int v3new = 101; |
| 1665 CX_TEST_ASSERT(cxListSet(list, 2, &v3new) == 0); |
1722 CX_TEST_ASSERT(cxListSet(list, 2, &v3new) == 0); |
| 1666 CX_TEST_ASSERT(*(int *) cxListAt(list, 2) == 101); |
1723 CX_TEST_ASSERT(*(int *) cxListLast(list) == 101); |
| 1667 |
1724 |
| 1668 // Try index out of bounds |
1725 // Try index out of bounds |
| 1669 int oob = 1337; |
1726 int oob = 1337; |
| 1670 CX_TEST_ASSERT(cxListSet(list, 3, &oob) != 0); |
1727 CX_TEST_ASSERT(cxListSet(list, 3, &oob) != 0); |
| 1671 }) |
1728 }) |
| 2011 cx_test_register(suite, test_list_parl_insert_array); |
2068 cx_test_register(suite, test_list_parl_insert_array); |
| 2012 cx_test_register(suite, test_list_arl_insert_sorted); |
2069 cx_test_register(suite, test_list_arl_insert_sorted); |
| 2013 cx_test_register(suite, test_list_parl_insert_sorted); |
2070 cx_test_register(suite, test_list_parl_insert_sorted); |
| 2014 cx_test_register(suite, test_list_arl_remove); |
2071 cx_test_register(suite, test_list_arl_remove); |
| 2015 cx_test_register(suite, test_list_parl_remove); |
2072 cx_test_register(suite, test_list_parl_remove); |
| |
2073 cx_test_register(suite, test_list_arl_remove_and_get); |
| |
2074 cx_test_register(suite, test_list_parl_remove_and_get); |
| 2016 cx_test_register(suite, test_list_arl_remove_array); |
2075 cx_test_register(suite, test_list_arl_remove_array); |
| 2017 cx_test_register(suite, test_list_parl_remove_array); |
2076 cx_test_register(suite, test_list_parl_remove_array); |
| 2018 cx_test_register(suite, test_list_arl_find_remove); |
2077 cx_test_register(suite, test_list_arl_find_remove); |
| 2019 cx_test_register(suite, test_list_parl_find_remove); |
2078 cx_test_register(suite, test_list_parl_find_remove); |
| 2020 cx_test_register(suite, test_list_arl_find_remove_sorted); |
2079 cx_test_register(suite, test_list_arl_find_remove_sorted); |
| 2114 cx_test_register(suite, test_list_pll_insert_array); |
2173 cx_test_register(suite, test_list_pll_insert_array); |
| 2115 cx_test_register(suite, test_list_ll_insert_sorted); |
2174 cx_test_register(suite, test_list_ll_insert_sorted); |
| 2116 cx_test_register(suite, test_list_pll_insert_sorted); |
2175 cx_test_register(suite, test_list_pll_insert_sorted); |
| 2117 cx_test_register(suite, test_list_ll_remove); |
2176 cx_test_register(suite, test_list_ll_remove); |
| 2118 cx_test_register(suite, test_list_pll_remove); |
2177 cx_test_register(suite, test_list_pll_remove); |
| |
2178 cx_test_register(suite, test_list_ll_remove_and_get); |
| |
2179 cx_test_register(suite, test_list_pll_remove_and_get); |
| 2119 cx_test_register(suite, test_list_ll_remove_array); |
2180 cx_test_register(suite, test_list_ll_remove_array); |
| 2120 cx_test_register(suite, test_list_pll_remove_array); |
2181 cx_test_register(suite, test_list_pll_remove_array); |
| 2121 cx_test_register(suite, test_list_ll_find_remove); |
2182 cx_test_register(suite, test_list_ll_find_remove); |
| 2122 cx_test_register(suite, test_list_pll_find_remove); |
2183 cx_test_register(suite, test_list_pll_find_remove); |
| 2123 cx_test_register(suite, test_list_ll_find_remove_sorted); |
2184 cx_test_register(suite, test_list_ll_find_remove_sorted); |