about summary refs log tree commit diff
path: root/malloc/tst-dynarray.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-06-13 17:03:56 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-06-13 21:55:10 +0200
commitf8bf87face3304f216bcd838081fa33bb4976ac6 (patch)
tree1dc3e2a512d5b040aa12c760a6b751b8916cbc9d /malloc/tst-dynarray.c
parenta65ea28d1833d3502c5070472e43bda04410e6b5 (diff)
downloadglibc-f8bf87face3304f216bcd838081fa33bb4976ac6.tar.gz
glibc-f8bf87face3304f216bcd838081fa33bb4976ac6.tar.xz
glibc-f8bf87face3304f216bcd838081fa33bb4976ac6.zip
dynarray: Implement begin/end functions in the spirit of C++
Diffstat (limited to 'malloc/tst-dynarray.c')
-rw-r--r--malloc/tst-dynarray.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/malloc/tst-dynarray.c b/malloc/tst-dynarray.c
index 7aee85aa39..2206d75e31 100644
--- a/malloc/tst-dynarray.c
+++ b/malloc/tst-dynarray.c
@@ -111,6 +111,13 @@ test_int (void)
                 }
               TEST_VERIFY_EXIT (dynarray_int_size (&dyn) == count);
               TEST_VERIFY_EXIT (count <= dyn.dynarray_header.allocated);
+              if (count > 0)
+                {
+                  TEST_VERIFY (dynarray_int_begin (&dyn)
+                               == dynarray_int_at (&dyn, 0));
+                  TEST_VERIFY (dynarray_int_end (&dyn)
+                               == dynarray_int_at (&dyn, count - 1) + 1);
+                }
               unsigned final_count;
               bool heap_array = dyn.dynarray_header.array != dyn.scratch;
               if (do_remove_last)
@@ -123,6 +130,13 @@ test_int (void)
                 }
               else
                 final_count = count;
+              if (final_count > 0)
+                {
+                  TEST_VERIFY (dynarray_int_begin (&dyn)
+                               == dynarray_int_at (&dyn, 0));
+                  TEST_VERIFY (dynarray_int_end (&dyn)
+                               == dynarray_int_at (&dyn, final_count - 1) + 1);
+                }
               if (do_clear)
                 {
                   dynarray_int_clear (&dyn);
@@ -225,6 +239,13 @@ test_str (void)
                 }
               TEST_VERIFY_EXIT (dynarray_str_size (&dyn) == count);
               TEST_VERIFY_EXIT (count <= dyn.dynarray_header.allocated);
+              if (count > 0)
+                {
+                  TEST_VERIFY (dynarray_str_begin (&dyn)
+                               == dynarray_str_at (&dyn, 0));
+                  TEST_VERIFY (dynarray_str_end (&dyn)
+                               == dynarray_str_at (&dyn, count - 1) + 1);
+                }
               unsigned final_count;
               bool heap_array = dyn.dynarray_header.array != dyn.scratch;
               if (do_remove_last)
@@ -237,6 +258,13 @@ test_str (void)
                 }
               else
                 final_count = count;
+              if (final_count > 0)
+                {
+                  TEST_VERIFY (dynarray_str_begin (&dyn)
+                               == dynarray_str_at (&dyn, 0));
+                  TEST_VERIFY (dynarray_str_end (&dyn)
+                               == dynarray_str_at (&dyn, final_count - 1) + 1);
+                }
               if (do_clear)
                 {
                   dynarray_str_clear (&dyn);