commit 66bf1ba94a7097b9c13760c68c1e535bbd9cae5a
parent dafdd8c02c6362f4e9c0ed60d839d939ed4baedf
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Thu, 30 Apr 2026 21:57:28 +0200
tests/libc: Add 0082-atoll
Diffstat:
3 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore
@@ -80,3 +80,4 @@ test.log
0079-atof
0080-atoi
0081-atol
+0082-atoll
diff --git a/tests/libc/execute/0082-atoll.c b/tests/libc/execute/0082-atoll.c
@@ -0,0 +1,63 @@
+#include <assert.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*
+output:
+testing
+done
+end:
+*/
+
+void
+test(void)
+{
+ long long n;
+ char buf[64];
+
+ n = atoll("abc");
+ assert(n == 0);
+
+ n = atoll(" abc");
+ assert(n == 0);
+
+ n = atoll("1234 ");
+ assert(n == 1234);
+
+ n = atoll(" 1234 0");
+ assert(n == 1234);
+
+ n = atoll("+");
+ assert(n == 0);
+
+ n = atoll(" +1");
+ assert(n == 1);
+
+ n = atoll("+ 1");
+ assert(n == 0);
+
+ n = atoll(" -1");
+ assert(n == -1);
+
+ n = atoll("- 1");
+ assert(n == 0);
+
+ sprintf(buf, "%lld", LONG_MAX);
+ n = atoll(buf);
+ assert(n == LLONG_MAX);
+
+ sprintf(buf, "%lld", LONG_MIN);
+ n = atoll(buf);
+ assert(n == LLONG_MIN);
+}
+
+int
+main()
+{
+ puts("testing");
+ test();
+ puts("done");
+
+ return 0;
+}
diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst
@@ -78,3 +78,4 @@
0079-atof [TODO]
0080-atoi
0081-atol
+0082-atoll