ReactOS  0.4.14-dev-583-g2a1ba2c
IsDBCSLeadByteEx.c
Go to the documentation of this file.
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 "precomp.h"
9 
10 #define MAX_RANGE 4
11 
12 typedef struct RANGE
13 {
15  int EndIndex;
16 } RANGE;
17 
18 typedef struct ENTRY
19 {
20  const char *Name;
21  int CodePage;
24 } ENTRY;
25 
27 {
28  static const ENTRY Entries[] =
29  {
30  {
31  "English", 437,
32  0
33  },
34  {
35  "ChineseSimpilified", 936,
36  1,
37  {
38  { 0x81, 0xFE }
39  }
40  },
41  {
42  "ChineseTraditional", 950,
43  1,
44  {
45  { 0x81, 0xFE }
46  }
47  },
48  {
49  "Japanese", 932,
50  2,
51  {
52  { 0x81, 0x9F }, { 0xE0, 0xFC }
53  }
54  },
55  {
56  "Korean", 949,
57  1,
58  {
59  { 0x81, 0xFE }
60  }
61  }
62  };
63  int i;
64 
65  for (i = 0; i < _countof(Entries); ++i)
66  {
67  int Index, iRange;
68  int CodePage = Entries[i].CodePage, StartIndex = 0, RangeCount = 0;
69  BOOL InRange = FALSE;
70  RANGE Ranges[MAX_RANGE];
71  const char *Name = Entries[i].Name;
72 
73  ZeroMemory(&Ranges, sizeof(Ranges));
74 
75  for (Index = 0; Index < 256; ++Index)
76  {
77  if (InRange)
78  {
79  if (!IsDBCSLeadByteEx(CodePage, Index))
80  {
81  Ranges[RangeCount].StartIndex = StartIndex;
82  Ranges[RangeCount].EndIndex = Index - 1;
83  ++RangeCount;
84  InRange = FALSE;
85  }
86  }
87  else
88  {
89  if (IsDBCSLeadByteEx(CodePage, Index))
90  {
91  StartIndex = Index;
92  InRange = TRUE;
93  }
94  }
95  }
96  if (InRange)
97  {
98  Ranges[RangeCount].StartIndex = StartIndex;
99  Ranges[RangeCount].EndIndex = Index - 1;
100  ++RangeCount;
101  }
102 
103  ok(RangeCount == Entries[i].RangeCount,
104  "%s: RangeCount expected %d, was %d\n",
105  Name, Entries[i].RangeCount, RangeCount);
106  for (iRange = 0; iRange < Entries[i].RangeCount; ++iRange)
107  {
108  const RANGE *pRange = &Entries[i].Ranges[iRange];
109  int iStart = Ranges[iRange].StartIndex;
110  int iEnd = Ranges[iRange].EndIndex;
111  ok(iStart == pRange->StartIndex,
112  "%s: Ranges[%d].StartIndex expected: 0x%02X, was: 0x%02X\n",
113  Name, iRange, pRange->StartIndex, iStart);
114  ok(iEnd == pRange->EndIndex,
115  "%s: Ranges[%d].EndIndex was expected: 0x%02X, was: 0x%02X\n",
116  Name, iRange, pRange->EndIndex, iEnd);
117  }
118  }
119 }
#define TRUE
Definition: types.h:120
int EndIndex
#define _countof(array)
Definition: fontsub.cpp:30
const char * Name
#define ZeroMemory
Definition: winbase.h:1642
_In_ UINT iStart
Definition: wingdi.h:3619
struct RANGE RANGE
int StartIndex
struct ENTRY ENTRY
#define MAX_RANGE
BOOL WINAPI IsDBCSLeadByteEx(UINT CodePage, BYTE TestByte)
Definition: nls.c:2210
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
START_TEST(IsDBCSLeadByteEx)
static const UCHAR Index[8]
Definition: usbohci.c:18
int CodePage
RANGE Ranges[MAX_RANGE]
LIST_ENTRY Entries[5]
Definition: ExDoubleList.c:8
#define ok(value,...)
Definition: atltest.h:57
int RangeCount