inet_pton tests, fix regression test case
[libc-test.git] / src / regression / printf-fmt-n.c
blob4d1c572e4c36bb35c12e83219e87b32b7e1d31b6
1 // commit: 5cbd76c6b05b381f269e0e204e10690d69f1d6ea 2011-02-16
2 // commit: bdc9ed15651b70e89f83c5a9f7d1ba349e624503 2011-02-20
3 // printf %n fmt
4 #include <stdint.h>
5 #include <stdio.h>
6 #include "test.h"
8 #define T(n,nfmt,fmt) do { \
9 if ((ret = sprintf(buf, "%256d%d" nfmt "%d", 1, 2, &n, 3)) != 258) \
10 t_error("expexted sprintf to write 258 chars, got %d\n", ret); \
11 if (n != 257) \
12 t_error("%%n format failed: wanted 257, got " fmt "\n", n); \
13 } while(0)
15 int main(void)
17 char buf[1024];
18 int ret;
19 int i;
20 long l;
21 long long ll;
22 short h;
23 size_t z;
24 uintmax_t j;
26 T(i, "%n", "%d");
27 T(l, "%ln", "%ld");
28 T(ll, "%lln", "%lld");
29 T(h, "%hn", "%d");
30 T(z, "%zn", "%zd");
31 T(j, "%jn", "%jd");
33 return t_status;