diff options
author | schwarze <> | 2014-09-19 12:32:08 +0000 |
---|---|---|
committer | schwarze <> | 2014-09-19 12:32:08 +0000 |
commit | 7010b1975cb00c045b15e4d4359d39e81710f38b (patch) | |
tree | 997c1d5e64567e0557d12b5f6baa0792674dedd2 /src | |
parent | bf714bcb520031b0db6d87858834fcfead2a3552 (diff) | |
download | openbsd-7010b1975cb00c045b15e4d4359d39e81710f38b.tar.gz openbsd-7010b1975cb00c045b15e4d4359d39e81710f38b.tar.bz2 openbsd-7010b1975cb00c045b15e4d4359d39e81710f38b.zip |
Fix on 32bit platforms where 0xdeadbeef > LONG_MAX.
To avoid making tests machine dependent, only test values inside 32bit
LONG_{MIN,MAX} and outside 64bit LONG_{MIN,MAX}, but none in between.
While here, cover 32bit edge cases, negative values, and overflows.
ok jsing@
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libc/strtol/strtoltest.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/regress/lib/libc/strtol/strtoltest.c b/src/regress/lib/libc/strtol/strtoltest.c index f7a8e0ab72..a90977a87d 100644 --- a/src/regress/lib/libc/strtol/strtoltest.c +++ b/src/regress/lib/libc/strtol/strtoltest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: strtoltest.c,v 1.1 2012/11/18 04:11:09 jsing Exp $ */ | 1 | /* $OpenBSD: strtoltest.c,v 1.2 2014/09/19 12:32:08 schwarze Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -16,6 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <errno.h> | 18 | #include <errno.h> |
19 | #include <limits.h> | ||
19 | #include <stdlib.h> | 20 | #include <stdlib.h> |
20 | #include <stdio.h> | 21 | #include <stdio.h> |
21 | #include <string.h> | 22 | #include <string.h> |
@@ -31,16 +32,17 @@ struct strtol_test { | |||
31 | struct strtol_test strtol_tests[] = { | 32 | struct strtol_test strtol_tests[] = { |
32 | {"1234567890", 1234567890L, '\0', 0, 0}, | 33 | {"1234567890", 1234567890L, '\0', 0, 0}, |
33 | {"0755", 493L, '\0', 0, 0}, | 34 | {"0755", 493L, '\0', 0, 0}, |
34 | {"0xdeadbeef", 3735928559L, '\0', 0, 0}, | 35 | {"0x7fFFffFf", 2147483647L, '\0', 0, 0}, |
35 | {"1234567890", 0L, '1', 1, EINVAL}, | 36 | {"1234567890", 0L, '1', 1, EINVAL}, |
36 | {"10101010", 170L, '\0', 2, 0}, | 37 | {"10101010", 170L, '\0', 2, 0}, |
37 | {"755", 493L, '\0', 8, 0}, | 38 | {"755", 493L, '\0', 8, 0}, |
38 | {"1234567890", 1234567890L, '\0', 10, 0}, | 39 | {"1234567890", 1234567890L, '\0', 10, 0}, |
39 | {"abc", 0L, 'a', 10, 0}, | 40 | {"abc", 0L, 'a', 10, 0}, |
40 | {"123xyz", 123L, 'x', 10, 0}, | 41 | {"123xyz", 123L, 'x', 10, 0}, |
41 | {"deadbeef", 3735928559L, '\0', 16, 0}, | 42 | {"-080000000", -2147483648L, '\0', 16, 0}, |
42 | {"DEADBEEF", 3735928559L, '\0', 16, 0}, | 43 | {"deadbeefdeadbeef", LONG_MAX, '\0', 16, ERANGE}, |
43 | {"deadzbeef", 57005L, 'z', 16, 0}, | 44 | {"deadzbeef", 57005L, 'z', 16, 0}, |
45 | {"-quitebig", LONG_MIN, '\0', 32, ERANGE}, | ||
44 | {"zzz", 46655L, '\0', 36, 0}, | 46 | {"zzz", 46655L, '\0', 36, 0}, |
45 | {"1234567890", 0L, '1', 37, EINVAL}, | 47 | {"1234567890", 0L, '1', 37, EINVAL}, |
46 | {"1234567890", 0L, '1', 123, EINVAL}, | 48 | {"1234567890", 0L, '1', 123, EINVAL}, |