diff options
author | Anton Kling <anton@kling.gg> | 2024-04-17 16:55:16 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-04-17 16:55:16 +0200 |
commit | d0cca44913356f8ce15e15216b0e26c2e74b4d06 (patch) | |
tree | f85f5360e528da9914cd4c45f4719d454711f012 /userland/test | |
parent | d3f8196eb2cd57fec5f6e2691fdbc802c4d92fc8 (diff) |
LibC: Add more functions that support "long long" integers
Diffstat (limited to 'userland/test')
-rw-r--r-- | userland/test/test.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/userland/test/test.c b/userland/test/test.c index 53fbf55..28e84d9 100644 --- a/userland/test/test.c +++ b/userland/test/test.c @@ -2,6 +2,7 @@ #include <fcntl.h> //#include <json.h> #include <ctype.h> +#include <errno.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> @@ -385,6 +386,22 @@ void strtol_test(void) { dbgln("strtol TEST PASSED"); } +void strtoll_test(void) { + dbgln("strtoll TEST"); + { + char *s = "9223372036854775807"; + char *e; + long r; + assert(9223372036854775807 == strtoll(s, &e, 10)); + assert(ERANGE != errno); + assert(e == (s + strlen(s))); + char *super_long = "92233720368547758070"; + assert(LLONG_MAX == strtoll(super_long, &e, 10)); + assert(ERANGE == errno); + } + dbgln("strtoll TEST PASSED"); +} + void strcmp_test(void) { #define EQ(_s1) \ { assert(0 == strcmp(_s1, _s1)); } @@ -796,6 +813,7 @@ int main(void) { strndup_test(); strspn_test(); strtol_test(); + strtoll_test(); strcmp_test(); strncmp_test(); strcasecmp_test(); |