[EXPLORER] -Use WM_POPUPSYSTEMMENU to open the system menu of a window. CORE-13400
[reactos.git] / rostests / apitests / kernel32 / IsDBCSLeadByteEx.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Tests for IsDBCSLeadByteEx
5 * PROGRAMMER: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8 #include <apitest.h>
9
10 #define WIN32_NO_STATUS
11 #define _INC_WINDOWS
12 #define COM_NO_WINDOWS_H
13 #include <stdio.h>
14 #include <winnls.h>
15
16 #define MAX_RANGE 4
17
18 typedef struct RANGE
19 {
20 int StartIndex;
21 int EndIndex;
22 } RANGE;
23
24 typedef struct ENTRY
25 {
26 const char *Name;
27 int CodePage;
28 int RangeCount;
29 RANGE Ranges[MAX_RANGE];
30 } ENTRY;
31
32 START_TEST(IsDBCSLeadByteEx)
33 {
34 static const ENTRY Entries[] =
35 {
36 {
37 "English", 437,
38 0
39 },
40 {
41 "ChineseSimpilified", 936,
42 1,
43 {
44 { 0x81, 0xFE }
45 }
46 },
47 {
48 "ChineseTraditional", 950,
49 1,
50 {
51 { 0x81, 0xFE }
52 }
53 },
54 {
55 "Japanese", 932,
56 2,
57 {
58 { 0x81, 0x9F }, { 0xE0, 0xFC }
59 }
60 },
61 {
62 "Korean", 949,
63 1,
64 {
65 { 0x81, 0xFE }
66 }
67 }
68 };
69 int i;
70
71 for (i = 0; i < _countof(Entries); ++i)
72 {
73 int Index, iRange;
74 int CodePage = Entries[i].CodePage, StartIndex = 0, RangeCount = 0;
75 BOOL InRange = FALSE;
76 RANGE Ranges[MAX_RANGE];
77 const char *Name = Entries[i].Name;
78
79 ZeroMemory(&Ranges, sizeof(Ranges));
80
81 for (Index = 0; Index < 256; ++Index)
82 {
83 if (InRange)
84 {
85 if (!IsDBCSLeadByteEx(CodePage, Index))
86 {
87 Ranges[RangeCount].StartIndex = StartIndex;
88 Ranges[RangeCount].EndIndex = Index - 1;
89 ++RangeCount;
90 InRange = FALSE;
91 }
92 }
93 else
94 {
95 if (IsDBCSLeadByteEx(CodePage, Index))
96 {
97 StartIndex = Index;
98 InRange = TRUE;
99 }
100 }
101 }
102 if (InRange)
103 {
104 Ranges[RangeCount].StartIndex = StartIndex;
105 Ranges[RangeCount].EndIndex = Index - 1;
106 ++RangeCount;
107 }
108
109 ok(RangeCount == Entries[i].RangeCount,
110 "%s: RangeCount expected %d, was %d\n",
111 Name, Entries[i].RangeCount, RangeCount);
112 for (iRange = 0; iRange < Entries[i].RangeCount; ++iRange)
113 {
114 const RANGE *pRange = &Entries[i].Ranges[iRange];
115 int iStart = Ranges[iRange].StartIndex;
116 int iEnd = Ranges[iRange].EndIndex;
117 ok(iStart == pRange->StartIndex,
118 "%s: Ranges[%d].StartIndex expected: 0x%02X, was: 0x%02X\n",
119 Name, iRange, pRange->StartIndex, iStart);
120 ok(iEnd == pRange->EndIndex,
121 "%s: Ranges[%d].EndIndex was expected: 0x%02X, was: 0x%02X\n",
122 Name, iRange, pRange->EndIndex, iEnd);
123 }
124 }
125 }