summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-03-02 14:58:14 -0500
committerJakob Kaivo <jkk@ung.org>2019-03-02 14:58:14 -0500
commit4bb6e449a91732a77a205a21a6af248d677f12fb (patch)
tree85359cd56bd44313072d11de634af3701124461f
parentc997061111200bd0fc68143215598c0a3bf1fc26 (diff)
some tests for atoi() and strtol()
-rw-r--r--stdlib.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/stdlib.c b/stdlib.c
index 1b59e1c..525a416 100644
--- a/stdlib.c
+++ b/stdlib.c
@@ -22,5 +22,13 @@ void test_stdlib_h(void)
test_true(NULL == 0);
test_min(RAND_MAX, 32767);
+ test_int_equals(atoi("100"), 100);
+ test_int_equals(atoi("-100"), -100);
+ test_long_equals(strtol("0xff", NULL, 0), 0xff);
+ test_long_equals(strtol(" +07777q", NULL, 0), 07777);
+ test_long_equals(strtol("-beef", NULL, 16), -0xbeef);
+ test_long_equals(strtol("zzzzzzzzzzzzzzzzzzzz", NULL, 36), LONG_MAX);
+ test_long_equals(strtol("-zzzzzzzzzzzzzzzzzzzz", NULL, 36), LONG_MIN);
+
testing_end();
}