uselocale(0) regression test
authorSzabolcs Nagy <nsz@port70.net>
Thu, 22 Jun 2017 23:28:25 +0000 (23:28 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Thu, 22 Jun 2017 23:28:25 +0000 (23:28 +0000)
src/regression/uselocale-0.c [new file with mode: 0644]

diff --git a/src/regression/uselocale-0.c b/src/regression/uselocale-0.c
new file mode 100644 (file)
index 0000000..b84e996
--- /dev/null
@@ -0,0 +1,29 @@
+// commit: 63f4b9f18f3674124d8bcb119739fec85e6da005
+// uselocale(0) should not change the current locale
+#include <locale.h>
+#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;
+}