diff options
| author | otto <> | 2004-09-18 19:31:32 +0000 |
|---|---|---|
| committer | otto <> | 2004-09-18 19:31:32 +0000 |
| commit | 6ddd43d6b3a20ac437f2353f6cdee1310bb9406e (patch) | |
| tree | dbc0778c26d27b816652afe3e56ea2333622a863 /src | |
| parent | 0fa4ed451a50f94cd114f54c2abdd0272c7b68c5 (diff) | |
| download | openbsd-6ddd43d6b3a20ac437f2353f6cdee1310bb9406e.tar.gz openbsd-6ddd43d6b3a20ac437f2353f6cdee1310bb9406e.tar.bz2 openbsd-6ddd43d6b3a20ac437f2353f6cdee1310bb9406e.zip | |
regress for 'z' and 't' modifiers
Diffstat (limited to '')
| -rw-r--r-- | src/regress/lib/libc/sprintf/sprintf_test.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/regress/lib/libc/sprintf/sprintf_test.c b/src/regress/lib/libc/sprintf/sprintf_test.c index cb93868b60..61c58f2f09 100644 --- a/src/regress/lib/libc/sprintf/sprintf_test.c +++ b/src/regress/lib/libc/sprintf/sprintf_test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sprintf_test.c,v 1.3 2004/09/16 20:22:26 otto Exp $ */ | 1 | /* $OpenBSD: sprintf_test.c,v 1.4 2004/09/18 19:31:32 otto Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2003 Theo de Raadt | 4 | * Copyright (c) 2003 Theo de Raadt |
| @@ -29,6 +29,7 @@ | |||
| 29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ | 30 | */ |
| 31 | 31 | ||
| 32 | #include <stddef.h> | ||
| 32 | #include <stdio.h> | 33 | #include <stdio.h> |
| 33 | #include <stdlib.h> | 34 | #include <stdlib.h> |
| 34 | #include <string.h> | 35 | #include <string.h> |
| @@ -48,10 +49,16 @@ char correct[] = | |||
| 48 | "|xx 41 42 43 44\n" | 49 | "|xx 41 42 43 44\n" |
| 49 | "|xx 45 -1 1 -1 1\n"; | 50 | "|xx 45 -1 1 -1 1\n"; |
| 50 | 51 | ||
| 52 | char correct2[] = | ||
| 53 | "1 0 -1 1 1 2 1 3 -1 4 1 \n" | ||
| 54 | "1 -1 1 1 -1 1 \n"; | ||
| 55 | |||
| 51 | int | 56 | int |
| 52 | main(int argc, char *argv[]) | 57 | main(int argc, char *argv[]) |
| 53 | { | 58 | { |
| 54 | char buf[1024]; | 59 | char buf[1024]; |
| 60 | size_t sz1, sz2, sz3, sz4; | ||
| 61 | ptrdiff_t p1, p2, p3, p4; | ||
| 55 | 62 | ||
| 56 | /* Test positional arguments */ | 63 | /* Test positional arguments */ |
| 57 | snprintf(buf, sizeof buf, | 64 | snprintf(buf, sizeof buf, |
| @@ -77,8 +84,19 @@ main(int argc, char *argv[]) | |||
| 77 | "43", "44", 45, -1L, 1LL, -1, 1LL | 84 | "43", "44", 45, -1L, 1LL, -1, 1LL |
| 78 | ); | 85 | ); |
| 79 | 86 | ||
| 80 | printf(buf); | 87 | if (strcmp(buf, correct) != 0) |
| 81 | if (strcmp(buf, correct) == 0) | 88 | exit(1); |
| 82 | exit(0); | 89 | |
| 83 | exit(1); | 90 | sz1 = (size_t)1; |
| 91 | sz2 = (size_t)-1; | ||
| 92 | p1 = (ptrdiff_t)1; | ||
| 93 | p2 = (ptrdiff_t)-1; | ||
| 94 | snprintf(buf, sizeof buf, | ||
| 95 | "%zx %d %zd %d %zu %d %tx %d %td %d %tu %zn %tn\n" | ||
| 96 | "%1$zx %3$zd %5$zu %7$tx %9$td %11$tu %14$zn %15$tn\n", | ||
| 97 | sz1, 0, sz2, 1, sz1, 2, p1, 3, p2, 4, p1, &sz3, &p3, &sz4, &p4); | ||
| 98 | if (strcmp(buf, correct2) != 0 || sz3 != 24 || p3 != 25 || | ||
| 99 | sz4 != 40 || p4 != 41) | ||
| 100 | exit(1); | ||
| 101 | exit(0); | ||
| 84 | } | 102 | } |
