From: Szabolcs Nagy Date: Thu, 22 Jun 2017 23:28:25 +0000 (+0000) Subject: uselocale(0) regression test X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=d891546b2de2436b459fdc95dc0390226bb1ad8b uselocale(0) regression test --- diff --git a/src/regression/uselocale-0.c b/src/regression/uselocale-0.c new file mode 100644 index 0000000..b84e996 --- /dev/null +++ b/src/regression/uselocale-0.c @@ -0,0 +1,29 @@ +// commit: 63f4b9f18f3674124d8bcb119739fec85e6da005 +// uselocale(0) should not change the current locale +#include +#include "test.h" + +int main(void) +{ + locale_t c = newlocale(LC_ALL_MASK, "C", 0); + + if (!c) { + t_error("newlocale failed\n"); + return t_status; + } + + if (!uselocale(c)) + t_error("uselocale(c) failed\n"); + + locale_t l1 = uselocale(0); + if (l1 != c) + t_error("uselocale failed to set locale: " + "%p != %p\n", (void*)l1, (void*)c); + + locale_t l2 = uselocale(0); + if (l2 != l1) + t_error("uselocale(0) changed locale: " + "%p != %p\n", (void*)l2, (void*)l1); + + return t_status; +}