]> git.saurik.com Git - apple/libc.git/blame - tests/locale.c
Libc-1439.100.3.tar.gz
[apple/libc.git] / tests / locale.c
CommitLineData
e1ee4b85 1#include <TargetConditionals.h>
974e3884
A
2#include <locale.h>
3#include <stdarg.h>
4#include <stdio.h>
5#include <wchar.h>
6#include <wctype.h>
7#include <xlocale.h>
8
9#include <darwintest.h>
10
e1ee4b85 11#if TARGET_OS_OSX
b061a43b 12T_DECL(locale_PR_23679075, "converts a cyrillic a to uppercase")
974e3884
A
13{
14 locale_t loc = newlocale(LC_COLLATE_MASK|LC_CTYPE_MASK, "ru_RU", 0);
15 T_ASSERT_NOTNULL(loc, "newlocale(LC_COLLATE_MASK|LC_CTYPE_MASK, \"ru_RU\", 0) should return a locale");
16
17 T_ASSERT_EQ(towupper_l(0x0430, loc), 0x0410, NULL);
18 freelocale(loc);
19}
20
b061a43b 21T_DECL(locale_PR_24165555, "swprintf with Russian chars")
974e3884
A
22{
23 setlocale(LC_ALL, "ru_RU.UTF-8");
24
25 wchar_t buffer[256];
26 T_EXPECT_POSIX_SUCCESS(swprintf(buffer, 256, L"%ls", L"English: Hello World"), "English");
27 T_EXPECT_POSIX_SUCCESS(swprintf(buffer, 256, L"%ls", L"Russian: ру́сский язы́к"), "Russian");
28
29 setlocale(LC_ALL, "");
30}
b061a43b
A
31
32T_DECL(locale_PR_28774201, "return code on bad locale")
33{
34 T_EXPECT_NULL(newlocale(LC_COLLATE_MASK | LC_CTYPE_MASK, "foobar", NULL), NULL);
35 T_EXPECT_EQ(errno, ENOENT, NULL);
36}
e1ee4b85 37#endif