From c1267dbfeb153c782e9690de8962aaf176ed0cdd Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 23 Mar 2026 11:35:54 +0100 Subject: tests: don't rely on unportable %p output --- test/09-init.c | 10 ++++++---- test/11-abi.c | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/test/09-init.c b/test/09-init.c index 6099a4d..2005840 100644 --- a/test/09-init.c +++ b/test/09-init.c @@ -7,8 +7,8 @@ U.x = 1 str[] -> "abcdef" strs -> "axcxdxbx" desgn1[] -> {0.000000,0.000000}, {1.000000,3.000000}, {-0.500000,0.000000} -desgn2 -> {(nil),{0,1.000000},(null)} -desgn3 -> {(nil),{{{-1},0.000000},{{0},0.000000},{{6},1.000000}},"k"} +desgn2 -> {0x0,{0,1.000000},(null)} +desgn3 -> {0x0,{{{-1},0.000000},{{0},0.000000},{{6},1.000000}},"k"} fi -> {1.500000 | 1069547520} arrdsgn[] -> {0,5,0,0,1} s -> "abc" @@ -61,6 +61,8 @@ void *rec[1] = {rec+1}; int static_eval = sizeof(char[ 1 ? 1 : 0/0]); +#include + int printf(char *, ...); int main() { printf("gexplicit[4] -> %d,%d,%d,%d\n", gexplicit[0], gexplicit[1], gexplicit[2], gexplicit[3]); @@ -71,8 +73,8 @@ int main() { printf("str[] -> \"%s\"\n", str); printf("strs -> \"%.*s\"\n", (int)sizeof strs, strs); printf("desgn1[] -> {%f,%f}, {%f,%f}, {%f,%f}\n", desgn1[0].x, desgn1[0].y, desgn1[1].x, desgn1[1].y, desgn1[2].x, desgn1[2].y); - printf("desgn2 -> {%p,{%d,%f},%s}\n", desgn2.j, desgn2.y, desgn2.z, desgn2.g); - printf("desgn3 -> {%p,{{{%d},%f},{{%d},%f},{{%d},%f}},\"%s\"}\n", desgn3.j, + printf("desgn2 -> {0x%"PRIxPTR",{%d,%f},%s}\n", desgn2.j, desgn2.y, desgn2.z, desgn2.g); + printf("desgn3 -> {0x%"PRIxPTR",{{{%d},%f},{{%d},%f},{{%d},%f}},\"%s\"}\n", desgn3.j, desgn3.a[0].y, desgn3.a[0].z, desgn3.a[1].y, desgn3.a[1].z, desgn3.a[2].y, desgn3.a[2].z, desgn3.g); printf("fi -> {%f | %d}\n", fi.f, fi.i); diff --git a/test/11-abi.c b/test/11-abi.c index 895b3ba..fcda498 100644 --- a/test/11-abi.c +++ b/test/11-abi.c @@ -1,11 +1,12 @@ /* EXPECT: -1 2 3 4 5 6 (nil) 9 abcdef +1 2 3 4 5 6 0x0 9 abcdef : 10, 20 1.000000 2.000000 3.000000 {4.000000,5.000000} -0.000000(80000000h) 99.000000 : -1.000000 */ #include +#include struct l { short s[10]; }; struct x { long p; }; @@ -13,8 +14,9 @@ struct ll { long a, b; }; struct ll f(int a, int b, struct l c, int d, int e, int f, void *g, struct x x, char *s) { printf("%d %d %d %d ", a, b, c.s[0], d); - printf("%d %d %p %ld %s\n", e, f, g, x.p, s); - return (struct ll){10,20}; + printf("%d %d 0x%"PRIxPTR" %ld %s\n", e, f, (intptr_t)g, x.p, s); + return (struct ll){10,20 + }; } struct f2 { float f[2]; }; -- cgit v1.2.3