scc

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

commit a2b366a3a88bbfee915c70244c9b10546c5f5cb9
parent 4aa1fb74928a33543c34f3f79c159ea3bfcb9be3
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Wed, 29 Apr 2026 15:55:38 +0200

tests/libc: Add 0077-setlocale

Diffstat:
Mtests/libc/execute/.gitignore | 1+
Atests/libc/execute/0077-setlocale.c | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtests/libc/execute/libc-tests.lst | 1+
3 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/tests/libc/execute/.gitignore b/tests/libc/execute/.gitignore @@ -75,3 +75,4 @@ test.log 0074-strftime 0075-strftime 0076-localeconv +0077-setlocale diff --git a/tests/libc/execute/0077-setlocale.c b/tests/libc/execute/0077-setlocale.c @@ -0,0 +1,67 @@ +#include <assert.h> +#include <locale.h> +#include <stdio.h> + +/* +output: +testing +done +end: +*/ + +static int neg, pos; + +static int +setup(void) +{ + neg = LC_ALL; + if (neg > LC_COLLATE) + neg = LC_COLLATE; + if (neg > LC_CTYPE) + neg = LC_CTYPE; + if (neg > LC_MONETARY) + neg = LC_MONETARY; + if (neg > LC_NUMERIC) + neg = LC_NUMERIC; + if (neg > LC_TIME) + neg = LC_TIME; + --neg; + + pos = LC_ALL; + if (pos < LC_COLLATE) + pos = LC_COLLATE; + if (pos < LC_CTYPE) + pos = LC_CTYPE; + if (pos < LC_MONETARY) + pos = LC_MONETARY; + if (pos < LC_NUMERIC) + pos = LC_NUMERIC; + if (pos < LC_TIME) + pos = LC_TIME; + ++pos; + + return 0; +} + +static void +run(void) +{ + char *l1, *l2; + + l1 = setlocale(pos, "C"); + l2 = setlocale(neg, "C"); + + assert(l1 == NULL); + assert(l2 == NULL); +} + +int +main(void) +{ + puts("testing"); + setup(); + run(); + puts("done"); + + return 0; +} diff --git a/tests/libc/execute/libc-tests.lst b/tests/libc/execute/libc-tests.lst @@ -73,3 +73,4 @@ 0074-strftime 0075-strftime 0076-localeconv +0077-setlocale