tests/test_list.c

changeset 1444
dd9dcbb39c2f
parent 1443
6986e9ed70f3
equal deleted inserted replaced
1443:6986e9ed70f3 1444:dd9dcbb39c2f
2572 2572
2573 // perform the test 2573 // perform the test
2574 int expected_data[12] = array_init(1, 2, 3, 4, 1, 3, 5, 7, 9, 11, 13, 15); 2574 int expected_data[12] = array_init(1, 2, 3, 4, 1, 3, 5, 7, 9, 11, 13, 15);
2575 int c = 0; 2575 int c = 0;
2576 test_clone_func_max_clones = 100; // no limit 2576 test_clone_func_max_clones = 100; // no limit
2577 size_t cloned = cxListClone(target, source, test_clone_func, testing_alloc, &c); 2577 CX_TEST_ASSERT(0 == cxListClone(target, source, test_clone_func, testing_alloc, &c));
2578 CX_TEST_ASSERT(cloned == 8);
2579 CX_TEST_ASSERT(c == 8); 2578 CX_TEST_ASSERT(c == 8);
2580 CX_TEST_ASSERT(cxListSize(target) == 12); 2579 CX_TEST_ASSERT(cxListSize(target) == 12);
2581 CX_TEST_ASSERT(cxListSize(source) == 8); 2580 CX_TEST_ASSERT(cxListSize(source) == 8);
2582 for (unsigned i = 0 ; i < 12 ; i++) { 2581 for (unsigned i = 0 ; i < 12 ; i++) {
2583 CX_TEST_ASSERT(*(int*)cxListAt(target, i) == expected_data[i]); 2582 CX_TEST_ASSERT(*(int*)cxListAt(target, i) == expected_data[i]);
2621 2620
2622 // perform the test 2621 // perform the test
2623 int expected_data[9] = array_init(1, 2, 3, 4, 1, 3, 5, 7, 9); 2622 int expected_data[9] = array_init(1, 2, 3, 4, 1, 3, 5, 7, 9);
2624 int c = 0; 2623 int c = 0;
2625 test_clone_func_max_clones = 5; 2624 test_clone_func_max_clones = 5;
2626 size_t cloned = cxListClone(target, source, test_clone_func, testing_alloc, &c); 2625 CX_TEST_ASSERT(0 != cxListClone(target, source, test_clone_func, testing_alloc, &c));
2627 CX_TEST_ASSERT(cloned == 5);
2628 CX_TEST_ASSERT(c == 5); 2626 CX_TEST_ASSERT(c == 5);
2629 CX_TEST_ASSERT(cxListSize(target) == 9); 2627 CX_TEST_ASSERT(cxListSize(target) == 9);
2630 CX_TEST_ASSERT(cxListSize(source) == 8); 2628 CX_TEST_ASSERT(cxListSize(source) == 8);
2631 for (unsigned i = 0 ; i < 9 ; i++) { 2629 for (unsigned i = 0 ; i < 9 ; i++) {
2632 CX_TEST_ASSERT(*(int*)cxListAt(target, i) == expected_data[i]); 2630 CX_TEST_ASSERT(*(int*)cxListAt(target, i) == expected_data[i]);

mercurial