1 /* Copyright (c) 2001-2004, Roger Dingledine.
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
7 #include "core/or/or.h"
13 /** Assert that <b>a</b> can be cast to void * and back. */
15 assert_int_voidptr_roundtrip(int a
)
17 intptr_t ap
= (intptr_t)a
;
19 intptr_t c
= (intptr_t)b
;
30 test_int_voidstar_interop(void *arg
)
35 for (a
= 0; a
<= 1024; a
++) {
36 assert_int_voidptr_roundtrip(a
);
39 for (a
= INT_MAX
-1024; a
< INT_MAX
; a
++) {
40 assert_int_voidptr_roundtrip(a
);
45 assert_uint_voidptr_roundtrip(unsigned int a
)
47 intptr_t ap
= (intptr_t)a
;
49 intptr_t c
= (intptr_t)b
;
60 test_uint_voidstar_interop(void *arg
)
65 for (a
= 0; a
<= 1024; a
++) {
66 assert_uint_voidptr_roundtrip(a
);
69 for (a
= UINT_MAX
-1024; a
< UINT_MAX
; a
++) {
70 assert_uint_voidptr_roundtrip(a
);
74 struct testcase_t slow_ptr_tests
[] = {
75 { .name
= "int_voidstar_interop",
76 .fn
= test_int_voidstar_interop
,
80 { .name
= "uint_voidstar_interop",
81 .fn
= test_uint_voidstar_interop
,