aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unit1309.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/tests/unit/unit1309.c b/tests/unit/unit1309.c
index 9a07c9332..7d3c00017 100644
--- a/tests/unit/unit1309.c
+++ b/tests/unit/unit1309.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -73,6 +73,7 @@ UNITTEST_START
struct Curl_tree *root, *removed;
struct Curl_tree nodes[NUM_NODES*3];
+ size_t storage[NUM_NODES*3];
int rc;
int i, j;
struct curltime tv_now = {0, 0};
@@ -81,14 +82,11 @@ UNITTEST_START
/* add nodes */
for(i = 0; i < NUM_NODES; i++) {
struct curltime key;
- size_t payload;
key.tv_sec = 0;
key.tv_usec = (541*i)%1023;
- payload = (size_t) key.tv_usec;
-
- /* for simplicity */
- nodes[i].payload = CURLX_INTEGER_TO_POINTER_CAST(payload);
+ storage[i] = key.tv_usec;
+ nodes[i].payload = &storage[i];
root = Curl_splayinsert(key, root, &nodes[i]);
}
@@ -99,8 +97,8 @@ UNITTEST_START
int rem = (i + 7)%NUM_NODES;
printf("Tree look:\n");
splayprint(root, 0, 1);
- printf("remove pointer %d, payload %ld\n", rem,
- CURLX_POINTER_TO_INTEGER_CAST(nodes[rem].payload));
+ printf("remove pointer %d, payload %zd\n", rem,
+ *(size_t *)nodes[rem].payload);
rc = Curl_splayremovebyaddr(root, &nodes[rem], &root);
if(rc) {
/* failed! */
@@ -120,9 +118,8 @@ UNITTEST_START
/* add some nodes with the same key */
for(j = 0; j <= i % 3; j++) {
- size_t payload = key.tv_usec*10 + j;
- /* for simplicity */
- nodes[i * 3 + j].payload = CURLX_INTEGER_TO_POINTER_CAST(payload);
+ storage[i * 3 + j] = key.tv_usec*10 + j;
+ nodes[i * 3 + j].payload = &storage[i * 3 + j];
root = Curl_splayinsert(key, root, &nodes[i * 3 + j]);
}
}
@@ -133,9 +130,9 @@ UNITTEST_START
tv_now.tv_usec = i;
root = Curl_splaygetbest(tv_now, root, &removed);
while(removed != NULL) {
- printf("removed payload %ld[%ld]\n",
- CURLX_POINTER_TO_INTEGER_CAST(removed->payload) / 10,
- CURLX_POINTER_TO_INTEGER_CAST(removed->payload) % 10);
+ printf("removed payload %zd[%zd]\n",
+ (*(size_t *)removed->payload) / 10,
+ (*(size_t *)removed->payload) % 10);
root = Curl_splaygetbest(tv_now, root, &removed);
}
}
@@ -143,7 +140,3 @@ UNITTEST_START
fail_unless(root == NULL, "tree not empty when it should be");
UNITTEST_STOP
-
-
-
-