summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2020-07-02 23:32:04 +0200
committerBenjamin Otte <otte@redhat.com>2020-07-16 18:09:57 +0200
commita4cd974912e404daa5b4078f1441fd7d93e64760 (patch)
tree38535ac4ec8269fedcb930da2dcd493177db6872 /testsuite
parent65359dcc5954d9191cc238d29d158726a2ab9c2b (diff)
downloadgtk+-a4cd974912e404daa5b4078f1441fd7d93e64760.tar.gz
array: Add null-termination
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gdk/array.c40
-rw-r--r--testsuite/gdk/arrayimpl.c11
2 files changed, 48 insertions, 3 deletions
diff --git a/testsuite/gdk/array.c b/testsuite/gdk/array.c
index d513b31a82..f9d5677b2c 100644
--- a/testsuite/gdk/array.c
+++ b/testsuite/gdk/array.c
@@ -50,6 +50,34 @@ int_free_func (int data)
#define GDK_ARRAY_FREE_FUNC int_free_func
#include "arrayimpl.c"
+#define GDK_ARRAY_ELEMENT_TYPE int
+#define GDK_ARRAY_NAME null_int_array
+#define GDK_ARRAY_TYPE_NAME NullIntVector
+#define GDK_ARRAY_NULL_TERMINATED 1
+#include "arrayimpl.c"
+
+#define GDK_ARRAY_ELEMENT_TYPE int
+#define GDK_ARRAY_NAME null_pre_int_array
+#define GDK_ARRAY_TYPE_NAME NullPreIntVector
+#define GDK_ARRAY_PREALLOC 100
+#define GDK_ARRAY_NULL_TERMINATED 1
+#include "arrayimpl.c"
+
+#define GDK_ARRAY_ELEMENT_TYPE int
+#define GDK_ARRAY_NAME null_free_int_array
+#define GDK_ARRAY_TYPE_NAME NullFreeIntVector
+#define GDK_ARRAY_FREE_FUNC int_free_func
+#define GDK_ARRAY_NULL_TERMINATED 1
+#include "arrayimpl.c"
+
+#define GDK_ARRAY_ELEMENT_TYPE int
+#define GDK_ARRAY_NAME null_pre_free_int_array
+#define GDK_ARRAY_TYPE_NAME NullPreFreeIntVector
+#define GDK_ARRAY_PREALLOC 100
+#define GDK_ARRAY_FREE_FUNC int_free_func
+#define GDK_ARRAY_NULL_TERMINATED 1
+#include "arrayimpl.c"
+
int
main (int argc, char *argv[])
{
@@ -59,11 +87,19 @@ main (int argc, char *argv[])
g_test_add_func ("/intarray/simple", int_array_test_simple);
g_test_add_func ("/intarray/prealloc/simple", pre_int_array_test_simple);
g_test_add_func ("/intarray/freefunc/simple", free_int_array_test_simple);
- g_test_add_func ("/intarray/prealloc_freefunc_simple", pre_free_int_array_test_simple);
+ g_test_add_func ("/intarray/prealloc/freefunc/simple", pre_free_int_array_test_simple);
+ g_test_add_func ("/intarray/null/simple", null_int_array_test_simple);
+ g_test_add_func ("/intarray/null/prealloc/simple", null_pre_int_array_test_simple);
+ g_test_add_func ("/intarray/null/freefunc/simple", null_free_int_array_test_simple);
+ g_test_add_func ("/intarray/null/prealloc/freefunc/simple", null_pre_free_int_array_test_simple);
g_test_add_func ("/intarray/splice", int_array_test_splice);
g_test_add_func ("/intarray/prealloc/splice", pre_int_array_test_splice);
g_test_add_func ("/intarray/freefunc/splice", free_int_array_test_splice);
- g_test_add_func ("/intarray/prealloc_freefunc_splice", pre_free_int_array_test_splice);
+ g_test_add_func ("/intarray/prealloc/freefunc/splice", pre_free_int_array_test_splice);
+ g_test_add_func ("/intarray/null/splice", null_int_array_test_splice);
+ g_test_add_func ("/intarray/null/prealloc/splice", null_pre_int_array_test_splice);
+ g_test_add_func ("/intarray/null/freefunc/splice", null_free_int_array_test_splice);
+ g_test_add_func ("/intarray/null/prealloc/freefunc/splice", null_pre_free_int_array_test_splice);
return g_test_run ();
}
diff --git a/testsuite/gdk/arrayimpl.c b/testsuite/gdk/arrayimpl.c
index f9320cb113..286f64d678 100644
--- a/testsuite/gdk/arrayimpl.c
+++ b/testsuite/gdk/arrayimpl.c
@@ -36,6 +36,9 @@ gdk_array(test_simple) (void)
g_assert_cmpint (gdk_array(get_size) (&v), ==, i);
g_assert_cmpint (gdk_array(get_size) (&v), <=, gdk_array(get_capacity) (&v));
gdk_array(append) (&v, i);
+#ifdef GDK_ARRAY_NULL_TERMINATED
+ g_assert_cmpint (*gdk_array(index) (&v, gdk_array(get_size) (&v)), ==, 0);
+#endif
}
g_assert_cmpint (gdk_array(get_size) (&v), ==, i);
g_assert_cmpint (gdk_array(get_size) (&v), <=, gdk_array(get_capacity) (&v));
@@ -84,6 +87,10 @@ gdk_array(test_splice) (void)
g_assert_cmpint (gdk_array(get_size) (&v), ==, old_size + add - remove);
g_assert_cmpint (gdk_array(get_size) (&v), <=, gdk_array(get_capacity) (&v));
+#ifdef GDK_ARRAY_NULL_TERMINATED
+ if (gdk_array(get_size) (&v))
+ g_assert_cmpint (*gdk_array(index) (&v, gdk_array(get_size) (&v)), ==, 0);
+#endif
for (j = 0; j < add; j++)
g_assert_cmpint (gdk_array(get) (&v, pos + j), ==, additions[j]);
}
@@ -100,9 +107,11 @@ gdk_array(test_splice) (void)
#undef gdk_array_paste_more
#undef gdk_array_paste
#undef gdk_array
+#undef GDK_ARRAY_REAL_SIZE
-#undef GDK_ARRAY_PREALLOC
#undef GDK_ARRAY_ELEMENT_TYPE
#undef GDK_ARRAY_NAME
#undef GDK_ARRAY_TYPE_NAME
+#undef GDK_ARRAY_PREALLOC
+#undef GDK_ARRAY_NULL_TERMINATED