aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_common_allocation.c
diff options
context:
space:
mode:
authorMarkus Teich <teichm@fs.tum.de>2016-09-07 22:31:05 +0000
committerMarkus Teich <teichm@fs.tum.de>2016-09-07 22:31:05 +0000
commit2a6a2e9713184f13df1972ca3b10004f0bccd282 (patch)
tree596a07b4b281eeffc8d0293b8e932ff48b593351 /src/util/test_common_allocation.c
parent939d0142629866734169ed7b2741aac7edd32cfc (diff)
downloadgnunet-2a6a2e9713184f13df1972ca3b10004f0bccd282.tar.gz
gnunet-2a6a2e9713184f13df1972ca3b10004f0bccd282.zip
gnunetutil: add 2d and 3d allocation including tests
Diffstat (limited to 'src/util/test_common_allocation.c')
-rw-r--r--src/util/test_common_allocation.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util/test_common_allocation.c b/src/util/test_common_allocation.c
index aa4809f58..4ef98b629 100644
--- a/src/util/test_common_allocation.c
+++ b/src/util/test_common_allocation.c
@@ -30,6 +30,8 @@ check ()
30{ 30{
31#define MAX_TESTVAL 1024 31#define MAX_TESTVAL 1024
32 char *ptrs[MAX_TESTVAL]; 32 char *ptrs[MAX_TESTVAL];
33 unsigned int **a2;
34 char ***a3;
33 int i; 35 int i;
34 int j; 36 int j;
35 int k; 37 int k;
@@ -93,6 +95,34 @@ check ()
93 if (ptrs[0] != NULL) 95 if (ptrs[0] != NULL)
94 return 9; 96 return 9;
95 97
98 /* GNUNET_new_array_2d tests */
99 a2 = GNUNET_new_array_2d (17, 22, unsigned int);
100 for (i = 0; i < 17; i++)
101 {
102 for (j = 0; j < 22; j++)
103 {
104 if (0 != a2[i][j])
105 return 10;
106 a2[i][j] = i * 100 + j;
107 }
108 }
109 free (a2);
110
111 /* GNUNET_new_array_3d tests */
112 a3 = GNUNET_new_array_3d (2, 3, 4, char);
113 for (i = 0; i < 2; i++)
114 {
115 for (j = 0; j < 3; j++)
116 {
117 for (k = 0; k < 4; k++)
118 {
119 if (0 != a3[i][j][k])
120 return 11;
121 a3[i][j][k] = i * 100 + j * 10 + k;
122 }
123 }
124 }
125 free (a3);
96 126
97 return 0; 127 return 0;
98} 128}