[glib/ebassi/aligned-alloc] fixup! Add tests for g_aligned_alloc()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/ebassi/aligned-alloc] fixup! Add tests for g_aligned_alloc()
- Date: Fri, 11 Feb 2022 13:50:21 +0000 (UTC)
commit 21a69f49d5ee91318b4f13d67781f4aa6befa944
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Feb 11 13:40:55 2022 +0000
fixup! Add tests for g_aligned_alloc()
glib/tests/utils.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index dcb35f75e..b4340c836 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -915,6 +915,17 @@ test_misc_mem (void)
g_assert (a == NULL);
}
+static void
+aligned_alloc_nz (void)
+{
+ gpointer a;
+
+ /* Test an alignment that’s zero */
+ a = g_aligned_alloc (16, sizeof(char), 0);
+ g_assert_null (a);
+ exit (0);
+}
+
static void
aligned_alloc_npot (void)
{
@@ -962,6 +973,7 @@ test_aligned_mem (void)
} \
} while (0)
+ CHECK_SUBPROCESS_FAIL (aligned_alloc_nz, "Alignment must not be zero");
CHECK_SUBPROCESS_FAIL (aligned_alloc_npot, "Alignment must be a power of two");
CHECK_SUBPROCESS_FAIL (aligned_alloc_nmov, "Alignment must be a multiple of sizeof(void*)");
}
@@ -1168,6 +1180,7 @@ main (int argc,
g_test_add_func ("/utils/clear-source", test_clear_source);
g_test_add_func ("/utils/misc-mem", test_misc_mem);
g_test_add_func ("/utils/aligned-mem", test_aligned_mem);
+ g_test_add_func ("/utils/aligned-mem/subprocess/aligned_alloc_nz", aligned_alloc_nz);
g_test_add_func ("/utils/aligned-mem/subprocess/aligned_alloc_npot", aligned_alloc_npot);
g_test_add_func ("/utils/aligned-mem/subprocess/aligned_alloc_nmov", aligned_alloc_nmov);
g_test_add_func ("/utils/aligned-mem/alignment", test_aligned_mem_alignment);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]