test/array_tests.c

branch
feature/array
changeset 344
320b962afaf9
parent 342
8f0a3c00d1d2
child 350
82a88d938108
     1.1 --- a/test/array_tests.c	Wed Aug 07 19:43:50 2019 +0200
     1.2 +++ b/test/array_tests.c	Wed Aug 07 20:45:21 2019 +0200
     1.3 @@ -257,6 +257,30 @@
     1.4      ucx_array_free(&a2);    
     1.5  }
     1.6  
     1.7 +UCX_TEST(test_ucx_array_at) {
     1.8 +    UcxArray array = ucx_array_new(16, sizeof(int));
     1.9 +    
    1.10 +    int x = 42;
    1.11 +    ucx_array_append(&array, &x);
    1.12 +    x = 13;
    1.13 +    ucx_array_append(&array, &x);
    1.14 +    x = 5;
    1.15 +    ucx_array_append(&array, &x);
    1.16 +    
    1.17 +    UCX_TEST_BEGIN
    1.18 +    
    1.19 +    UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 1) == 13, "failed");
    1.20 +    *(int*)ucx_array_at(array, 1) = 80;
    1.21 +    UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 1) == 80, "assignment failed");
    1.22 +    
    1.23 +    UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 0) == 42, "corrupted data");
    1.24 +    UCX_TEST_ASSERT(*(int*)ucx_array_at(array, 2) == 5, "corrupted data");
    1.25 +    
    1.26 +    UCX_TEST_END
    1.27 +    
    1.28 +    ucx_array_free(&array);
    1.29 +}
    1.30 +
    1.31  UCX_TEST(test_ucx_array_find) {
    1.32      UcxArray array = ucx_array_new(16, sizeof(int));
    1.33      int *elems;

mercurial