scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 0ee5b49181c1813e136046ad648f909fe6102ea4
parent f9dd9d11f059550c22ff819080400574d515da8e
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Fri,  1 May 2026 19:55:24 +0200

tests/libc: Add 0095-abs

Diffstat:
Mtests/libc/execute/.gitignore | 1+
Atests/libc/execute/0095-abs.c | 32++++++++++++++++++++++++++++++++
Mtests/libc/execute/libc-tests.lst | 1+
3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore @@ -93,3 +93,4 @@ test.log 0092-getenv 0093-system 0094-bsearch +0095-abs diff --git a/tests/libc/execute/0095-abs.c b/tests/libc/execute/0095-abs.c @@ -0,0 +1,32 @@ +#include <assert.h> +#include <inttypes.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> + +/* +output: +testing +done +end: +*/ + +int +main(void) +{ + puts("testing"); + assert(abs(3) == abs(-3)); + assert(abs(-INT_MAX) == INT_MAX); + + assert(labs(3) == labs(-3)); + assert(labs(-LONG_MAX) == LONG_MAX); + + assert(llabs(3) == llabs(-3)); + assert(llabs(-LLONG_MAX) == LONG_MAX); + + assert(imaxabs(3) == imaxabs(-3)); + assert(imaxabs(-INTMAX_MAX) == INTMAX_MAX); + puts("done"); + + return 0; +} diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst @@ -91,3 +91,4 @@ 0092-getenv 0093-system 0094-bsearch +0095-abs