1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | /*============================================================================ |
6 | ** |
7 | ** Source: test1.c |
8 | ** |
9 | ** Purpose: Tests that IsDBCSLeadByteEx does not find any lead-bytes in the |
10 | ** current ansi code page or the default code page. Also tests that |
11 | ** it correctly handles an invalid codepage. |
12 | ** |
13 | ** |
14 | **==========================================================================*/ |
15 | |
16 | |
17 | #include <palsuite.h> |
18 | |
19 | void DoTest(int codepage) |
20 | { |
21 | int value; |
22 | int ret; |
23 | int i; |
24 | |
25 | |
26 | for (i=0; i<256; i++) |
27 | { |
28 | value = IsDBCSLeadByteEx(codepage, i); |
29 | |
30 | ret = GetLastError(); |
31 | if (ret == ERROR_INVALID_PARAMETER) |
32 | { |
33 | Fail("IsDBCSLeadByteEx unexpectedly errored with ERROR_INVALID_PARAMETER!\n" ); |
34 | } |
35 | else if (ret != 0) |
36 | { |
37 | Fail("IsDBCSLeadByteEx had an unexpected error!\n" ); |
38 | } |
39 | else if (value) |
40 | { |
41 | Fail("IsDBCSLeadByteEx incorrectly found a lead byte in code " |
42 | "page %d\n" , codepage); |
43 | } |
44 | |
45 | } |
46 | } |
47 | |
48 | int __cdecl main(int argc, char *argv[]) |
49 | { |
50 | |
51 | if (0 != PAL_Initialize(argc, argv)) |
52 | { |
53 | return FAIL; |
54 | } |
55 | |
56 | if (IsDBCSLeadByteEx(-1, 0)) |
57 | { |
58 | Fail("IsDBCSLeadByteEx did not error on an invalid code page!\n" ); |
59 | } |
60 | |
61 | /* Clear the last error. */ |
62 | SetLastError(0); |
63 | |
64 | |
65 | DoTest(0); |
66 | DoTest(CP_ACP); |
67 | |
68 | PAL_Terminate(); |
69 | |
70 | return PASS; |
71 | } |
72 | |
73 | |