ReactOS 0.4.17-dev-150-g85f2a67
EnumSystemCodePages.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Test for EnumSystemCodePages
5 * COPYRIGHT: Copyright 2026 Aliaksandr Lebiadzevich <bsalex2025@gmail.com>
6 * Copyright 2026 Stanislav Motylkov <x86corez@gmail.com>
7 */
8
9#include "precomp.h"
10
11char* func = NULL;
13
14BOOL
17 LPWSTR lpCodePageString)
18{
19 ULONG CodePage = 0;
20 int ret = swscanf(lpCodePageString, L"%u", &CodePage);
21
22 ok(ret == 1, "%s: '%S' is not a valid number\n", func, lpCodePageString);
23 if (ret == 1)
24 trace("%s: '%S' is a valid number (%lu)\n", func, lpCodePageString, CodePage);
25
26 cntLast++;
27 return TRUE;
28}
29
30BOOL
33 LPSTR lpCodePageString)
34{
35 BOOL ret;
36 int len = MultiByteToWideChar(CP_ACP, 0, lpCodePageString, -1, NULL, 0);
37 WCHAR *str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
38 if (!str)
39 return FALSE;
40
41 MultiByteToWideChar(CP_ACP, 0, lpCodePageString, -1, str, len);
44
45 return ret;
46}
47
48typedef struct ENTRY
49{
54
55VOID
57 BOOL Ansi)
58{
59 BOOL ret;
60 int i;
61
62 static const ENTRY Tests[] =
63 {
64 { /* 1 */ CP_INSTALLED, TRUE, 0xDEADF00D },
65 { /* 2 */ CP_SUPPORTED, TRUE, 0xDEADF00D },
66 { 0, TRUE, 0xDEADF00D }, /* Windows handles this as CP_SUPPORTED */
69 };
70
71 for (i = 0; i < _countof(Tests); i++)
72 {
73 cntLast = 0;
74 SetLastError(Tests[0].dwError);
75 func = Ansi
76 ? "EnumSystemCodePagesA"
77 : "EnumSystemCodePagesW";
78 ret = Ansi
81 if (ret) trace("%s enumerated %u entries\n", func, cntLast);
82 ok(Tests[i].bReturn == ret, "%s unexpected return: %u, expected %u\n", func, ret, Tests[i].bReturn);
83 ok(Tests[i].dwError == GetLastError(), "%s unexpected error: %u, expected %u\n", func, GetLastError(), Tests[i].dwError);
84
86 {
88 ok(cntInstalled > 0, "No installed codepages enumerated\n");
89 }
90 else if (Tests[i].dwFlags == CP_SUPPORTED)
91 {
93 ok(cntSupported > 0, "No supported codepages enumerated\n");
94 }
95 else if (Tests[i].dwFlags == 0)
96 ok(cntLast == cntSupported, "Number of codepages expected: %u, got %u\n", cntSupported, cntLast);
97 }
98}
99
101{
104}
struct ENTRY ENTRY
ULONG cntSupported
BOOL CALLBACK EnumCodePagesProcW(LPWSTR lpCodePageString)
ULONG cntInstalled
BOOL CALLBACK EnumCodePagesProcA(LPSTR lpCodePageString)
VOID RunEnumTests(BOOL Ansi)
ULONG cntLast
struct test_data Tests[]
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI EnumSystemCodePagesW(CODEPAGE_ENUMPROCW lpfnCodePageEnum, DWORD flags)
Definition: locale.c:2297
BOOL WINAPI EnumSystemCodePagesA(CODEPAGE_ENUMPROCA lpfnCodePageEnum, DWORD flags)
Definition: locale.c:2276
_ACRTIMP int __cdecl swscanf(const wchar_t *, const wchar_t *,...)
Definition: scanf.c:438
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum func
Definition: glext.h:6028
GLenum GLsizei len
Definition: glext.h:6722
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
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define DWORD
Definition: nt_native.h:44
short WCHAR
Definition: pedump.c:58
const WCHAR * str
#define _countof(array)
Definition: sndvol32.h:70
Definition: DelNode.c:62
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INVALID_FLAGS
Definition: winerror.h:907
#define EnumSystemCodePages
Definition: winnls.h:1349
#define CP_INSTALLED
Definition: winnls.h:212
#define CP_SUPPORTED
Definition: winnls.h:213