#include #include #include #include static ptrdiff_t testvals[] = { -INT_MAX, -1, 0, 1, 2, 17, INT_MAX, }; int main(void) { int i; /* This is how many tests you plan to run */ plan_tests(2 * ARRAY_SIZE(testvals)); for (i = 0; i < ARRAY_SIZE(testvals); i++) { ptrdiff_t val = testvals[i]; void *ptr = int2ptr(val); ok1(ptr2int(ptr) == val); ok1(!val == !ptr); } /* This exits depending on whether all tests passed */ return exit_status(); }