1 /*
2  * PROJECT:     ReactOS api tests
3  * LICENSE:     LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4  * PURPOSE:     Tests for LCMapString
5  * COPYRIGHT:   Copyright 2024 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 
8 #include "precomp.h"
9 
10 #undef ok_wstr_
11 
12 static void
ok_wstr_(const char * file,int line,LPCWSTR x,LPCWSTR y)13 ok_wstr_(const char *file, int line, LPCWSTR x, LPCWSTR y)
14 {
15     char buf1[100], buf2[100];
16     lstrcpynA(buf1, wine_dbgstr_w(x), _countof(buf1));
17     lstrcpynA(buf2, wine_dbgstr_w(y), _countof(buf2));
18     ok_(file, line)(wcscmp(x, y) == 0, "Wrong string. Expected %s, got %s\n", buf2, buf1);
19 }
20 
21 #undef ok_wstr
22 #define ok_wstr(x, y)     ok_wstr_(__FILE__, __LINE__, x, y)
23 
24 // "ABab12ABab12あアばバパ万萬" in UTF-16
25 static const WCHAR c_target[] =
26     L"ABab12\xff21\xff22\xff41\xff42\xff11\xff12\x3042\x30a2\x3070\x30d0\xff8a\xff9f\x4e07\x842c";
27 
TEST_LCMapStringW(void)28 static void TEST_LCMapStringW(void)
29 {
30     WCHAR results[100];
31 
32     LCMapStringW(0, LCMAP_FULLWIDTH, c_target, -1, results, _countof(results));
33     ok_wstr(results, L"\xff21\xff22\xff41\xff42\xff11\xff12\xff21\xff22\xff41\xff42\xff11\xff12\x3042\x30a2\x3070\x30d0\x30d1\x4e07\x842c");
34 
35     LCMapStringW(0, LCMAP_HALFWIDTH, c_target, -1, results, _countof(results));
36     ok_wstr(results, L"ABab12ABab12\x3042\xff71\x3070\xff8a\xff9e\xff8a\xff9f\x4e07\x842c");
37 
38     LCMapStringW(0, LCMAP_HIRAGANA, c_target, -1, results, _countof(results));
39     ok_wstr(results, L"ABab12\xff21\xff22\xff41\xff42\xff11\xff12\x3042\x3042\x3070\x3070\xff8a\xff9f\x4e07\x842c");
40 
41     LCMapStringW(0, LCMAP_KATAKANA, c_target, -1, results, _countof(results));
42     ok_wstr(results, L"ABab12\xff21\xff22\xff41\xff42\xff11\xff12\x30a2\x30a2\x30d0\x30d0\xff8a\xff9f\x4e07\x842c");
43 
44     LCMapStringW(0, LCMAP_LOWERCASE, c_target, -1, results, _countof(results));
45     ok_wstr(results, L"abab12\xff41\xff42\xff41\xff42\xff11\xff12\x3042\x30a2\x3070\x30d0\xff8a\xff9f\x4e07\x842c");
46 
47     LCMapStringW(0, LCMAP_UPPERCASE, c_target, -1, results, _countof(results));
48     ok_wstr(results, L"ABAB12\xff21\xff22\xff21\xff22\xff11\xff12\x3042\x30a2\x3070\x30d0\xff8a\xff9f\x4e07\x842c");
49 
50     LCMapStringW(0, LCMAP_SIMPLIFIED_CHINESE, c_target, -1, results, _countof(results));
51     ok_wstr(results, L"ABab12\xff21\xff22\xff41\xff42\xff11\xff12\x3042\x30a2\x3070\x30d0\xff8a\xff9f\x4e07\x4e07");
52 
53     LCMapStringW(0, LCMAP_TRADITIONAL_CHINESE, c_target, -1, results, _countof(results));
54     ok_wstr(results, L"ABab12\xff21\xff22\xff41\xff42\xff11\xff12\x3042\x30a2\x3070\x30d0\xff8a\xff9f\x842c\x842c");
55 }
56 
START_TEST(LCMapString)57 START_TEST(LCMapString)
58 {
59     TEST_LCMapStringW();
60 }
61