reverts deletion of tests for ucx_array_at() feature/array

Wed, 07 Aug 2019 20:45:21 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 07 Aug 2019 20:45:21 +0200
branch
feature/array
changeset 344
320b962afaf9
parent 343
c09da4ee177f
child 345
6089eb30a51a

reverts deletion of tests for ucx_array_at()

test/array_tests.c file | annotate | diff | comparison | revisions
test/array_tests.h file | annotate | diff | comparison | revisions
test/main.c file | annotate | diff | comparison | revisions
--- 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;
--- 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);
--- 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);

mercurial