diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-24 15:02:49 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-24 15:02:49 +1000 |
commit | 3cafe0e80b6f57115bc059e26f11c5d613112984 (patch) | |
tree | e088a573396a3c97c80d97140392d9a77e9813ce /libc/test | |
parent | 11dfb25fae9d0f92de5c10ba4ef08a7ff8e88410 (diff) | |
download | skiboot-3cafe0e80b6f57115bc059e26f11c5d613112984.zip skiboot-3cafe0e80b6f57115bc059e26f11c5d613112984.tar.gz skiboot-3cafe0e80b6f57115bc059e26f11c5d613112984.tar.bz2 |
add tests for libc isdigit, isprint, isspace, isxdigit
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libc/test')
-rw-r--r-- | libc/test/run-ctype-test.c | 24 | ||||
-rw-r--r-- | libc/test/run-ctype.c | 69 |
2 files changed, 93 insertions, 0 deletions
diff --git a/libc/test/run-ctype-test.c b/libc/test/run-ctype-test.c index 5ba76f1..999292b 100644 --- a/libc/test/run-ctype-test.c +++ b/libc/test/run-ctype-test.c @@ -31,3 +31,27 @@ #include "../ctype/tolower.c" #include "../ctype/toupper.c" +int skiboot_isdigit(int ch); +int skiboot_isprint(int ch); +int skiboot_isspace(int ch); +int skiboot_isxdigit(int ch); + +int skiboot_isdigit(int ch) +{ + return isdigit(ch); +} + +int skiboot_isprint(int ch) +{ + return isprint(ch); +} + +int skiboot_isspace(int ch) +{ + return isspace(ch); +} + +int skiboot_isxdigit(int ch) +{ + return isxdigit(ch); +} diff --git a/libc/test/run-ctype.c b/libc/test/run-ctype.c index 15ec9bd..eac04ec 100644 --- a/libc/test/run-ctype.c +++ b/libc/test/run-ctype.c @@ -20,8 +20,77 @@ #include <assert.h> #include <string.h> #include <stdio.h> +#include <assert.h> +#include <ctype.h> + +int skiboot_isdigit(int ch); +int skiboot_isprint(int ch); +int skiboot_isspace(int ch); +int skiboot_isxdigit(int ch); int main(void) { + int i; + int r1, r2; + + for(i = '0'; i <= '9'; i++) + assert(skiboot_isdigit(i)); + assert(skiboot_isdigit('a') == 0); + assert(skiboot_isdigit('Z') == 0); + + for (i = 0; i < 257; i++) { + r1 = skiboot_isdigit(i); + r2 = isdigit(i); + if (r1) + assert(r2); + if (!r1) + assert(!r2); + } + + for(i = '0'; i <= '9'; i++) + assert(skiboot_isprint(i)); + assert(skiboot_isprint('\0') == 0); + assert(skiboot_isprint(4) == 0); + + for (i = 0; i < 257; i++) { + r1 = skiboot_isprint(i); + r2 = isprint(i); + if (r1) + assert(r2); + if (!r1) + assert(!r2); + } + + for(i = '0'; i <= '9'; i++) + assert(skiboot_isspace(i) == 0); + assert(skiboot_isspace('\f')); + assert(skiboot_isspace('\n')); + assert(skiboot_isspace(' ')); + + for (i = 0; i < 257; i++) { + r1 = skiboot_isspace(i); + r2 = isspace(i); + if (r1) + assert(r2); + if (!r1) + assert(!r2); + } + + for(i = '0'; i <= '9'; i++) + assert(skiboot_isxdigit(i)); + assert(skiboot_isxdigit('a')); + assert(skiboot_isxdigit('A')); + assert(skiboot_isxdigit('F')); + assert(skiboot_isxdigit('Z') == 0); + + for (i = 0; i < 257; i++) { + r1 = skiboot_isxdigit(i); + r2 = isxdigit(i); + if (r1) + assert(r2); + if (!r1) + assert(!r2); + } + return 0; } |