[WIN32KNT_APITEST] Add NtUserGetKeyboardLayoutName testcase (#4594)
[reactos.git] / modules / rostests / apitests / win32nt / ntuser / NtUserGetKeyboardLayoutName.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: Test for NtUserGetKeyboardLayoutName
5 * COPYRIGHT: Copyright 2022 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8 #include <win32nt.h>
9 #include <pseh/pseh2.h>
10
11 typedef BOOL (APIENTRY *FN_NtUserGetKeyboardLayoutName)(PVOID);
12
13 START_TEST(NtUserGetKeyboardLayoutName)
14 {
15 FN_NtUserGetKeyboardLayoutName fn = (FN_NtUserGetKeyboardLayoutName)NtUserGetKeyboardLayoutName;
16 UNICODE_STRING ustr;
17 WCHAR szBuff[MAX_PATH];
18 BOOL bHung;
19
20 /* Try NULL */
21 ok_int(fn(NULL), 0);
22
23 /* Try szBuff */
24 bHung = FALSE;
25 szBuff[0] = 0;
26 _SEH2_TRY
27 {
28 fn(szBuff);
29 }
30 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
31 {
32 bHung = TRUE;
33 }
34 _SEH2_END;
35
36 ok_int(bHung, FALSE);
37 ok(szBuff[0] == 0, "szBuff[0] was %d\n", szBuff[0]);
38
39 /* Try ustr */
40 szBuff[0] = 0;
41 ustr.Buffer = szBuff;
42 ustr.Length = 0;
43 ustr.MaximumLength = RTL_NUMBER_OF(szBuff);
44 bHung = FALSE;
45 _SEH2_TRY
46 {
47 fn(&ustr);
48 }
49 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
50 {
51 bHung = TRUE;
52 }
53 _SEH2_END;
54
55 ok_int(bHung, FALSE);
56 ok(szBuff[0] != 0, "szBuff[0] was %d\n", szBuff[0]);
57 }