[SHELL32_APITEST] -Add tests for Control_RunDLLW.
[reactos.git] / rostests / kmtests / rtl / RtlIsValidOemCharacter.c
1 /*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Runtime library for RtlIsValidOemCharacter
5 * PROGRAMMER: Dmitry Chapyshev <dmitry@reactos.org>
6 */
7
8 #define KMT_EMULATE_KERNEL
9 #include <kmt_test.h>
10
11 START_TEST(RtlIsValidOemCharacter)
12 {
13 const WCHAR ValidCharsEn[] = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!#$%^&*()_+|`:;\"'-/\\ ";
14 const WCHAR InvalidChars[] = L"?\x0372\x03CF\x3D5F";
15 WCHAR unicode_null = UNICODE_NULL;
16 WCHAR tmp;
17 BOOLEAN res;
18 INT i;
19 NTSTATUS Status = STATUS_SUCCESS;
20
21 res = RtlIsValidOemCharacter(&unicode_null);
22 ok(res != FALSE, "UNICODE_NULL is valid char\n");
23
24 /* Test for valid chars */
25 for (i = 0; i < (sizeof(ValidCharsEn) / sizeof(WCHAR)) - 1; i++)
26 {
27 tmp = ValidCharsEn[i];
28
29 res = RtlIsValidOemCharacter(&tmp);
30 ok(res != FALSE, "Expected success. '%C' [%d] is valid char\n", ValidCharsEn[i], i);
31 ok(tmp == RtlUpcaseUnicodeChar(ValidCharsEn[i]), "Expected upcase char for '%C' [%d]\n", ValidCharsEn[i], i);
32
33 tmp = RtlUpcaseUnicodeChar(ValidCharsEn[i]);
34 res = RtlIsValidOemCharacter(&tmp);
35 ok(res != FALSE, "Expected success. '%C' [%d] is valid char\n", ValidCharsEn[i], i);
36 ok(tmp == RtlUpcaseUnicodeChar(ValidCharsEn[i]), "Expected upcase char for '%C' [%d]\n", ValidCharsEn[i], i);
37 }
38
39 /* Test for invalid chars */
40 for (i = 0; i < (sizeof(InvalidChars) / sizeof(WCHAR)) - 1; i++)
41 {
42 tmp = InvalidChars[i];
43
44 res = RtlIsValidOemCharacter(&tmp);
45 ok(res == FALSE, "Expected fail. '%C' [%d] is NOT valid char\n", InvalidChars[i], i);
46 ok(tmp == RtlUpcaseUnicodeChar(InvalidChars[i]), "Expected upcase char for '%C' [%d]\n", InvalidChars[i], i);
47
48 tmp = RtlUpcaseUnicodeChar(InvalidChars[i]);
49 res = RtlIsValidOemCharacter(&tmp);
50 ok(res == FALSE, "Expected fail. '%C' [%d] is NOT valid char\n", InvalidChars[i], i);
51 ok(tmp == RtlUpcaseUnicodeChar(InvalidChars[i]), "Expected upcase char for '%C' [%d]\n", InvalidChars[i], i);
52 }
53
54 _SEH2_TRY
55 {
56 RtlIsValidOemCharacter(NULL);
57 }
58 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
59 {
60 /* Get the exception code */
61 Status = _SEH2_GetExceptionCode();
62 }
63 _SEH2_END;
64
65 ok(!NT_SUCCESS(Status), "Exception is expected but it did not occur\n");
66 }
67