# HG changeset patch # User Mike Becker # Date 1565203521 -7200 # Node ID 320b962afaf9a84ce190a04c0dc8fc0238502478 # Parent c09da4ee177f41c3fbfe20cbc515929d3dc73571 reverts deletion of tests for ucx_array_at() diff -r c09da4ee177f -r 320b962afaf9 test/array_tests.c --- a/test/array_tests.c Wed Aug 07 19:43:50 2019 +0200 +++ b/test/array_tests.c Wed Aug 07 20:45:21 2019 +0200 @@ -257,6 +257,30 @@ ucx_array_free(&a2); } +UCX_TEST(test_ucx_array_at) { + UcxArray array = ucx_array_new(16, sizeof(int)); + + int x = 42; + ucx_array_append(&array, &x); + x = 13; + ucx_array_append(&array, &x); + x = 5; + ucx_array_append(&array, &x); + + UCX_TEST_BEGIN + + UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 1) == 13, "failed"); + *(int*)ucx_array_at(array, 1) = 80; + UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 1) == 80, "assignment failed"); + + UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 0) == 42, "corrupted data"); + UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 2) == 5, "corrupted data"); + + UCX_TEST_END + + ucx_array_free(&array); +} + UCX_TEST(test_ucx_array_find) { UcxArray array = ucx_array_new(16, sizeof(int)); int *elems; diff -r c09da4ee177f -r 320b962afaf9 test/array_tests.h --- a/test/array_tests.h Wed Aug 07 19:43:50 2019 +0200 +++ b/test/array_tests.h Wed Aug 07 20:45:21 2019 +0200 @@ -38,6 +38,7 @@ UCX_TEST(test_ucx_array_free); UCX_TEST(test_ucx_array_new); +UCX_TEST(test_ucx_array_at); UCX_TEST(test_ucx_array_append); UCX_TEST(test_ucx_array_prepend); UCX_TEST(test_ucx_array_set); diff -r c09da4ee177f -r 320b962afaf9 test/main.c --- a/test/main.c Wed Aug 07 19:43:50 2019 +0200 +++ b/test/main.c Wed Aug 07 20:45:21 2019 +0200 @@ -145,6 +145,7 @@ /* UcxArray Tests */ ucx_test_register(suite, test_ucx_array_free); ucx_test_register(suite, test_ucx_array_new); + ucx_test_register(suite, test_ucx_array_at); ucx_test_register(suite, test_ucx_array_append); ucx_test_register(suite, test_ucx_array_prepend); ucx_test_register(suite, test_ucx_array_set);