Author: dchapyshev
Date: Sun Aug 28 15:59:29 2016
New Revision: 72487
URL:
http://svn.reactos.org/svn/reactos?rev=72487&view=rev
Log:
[ADVAPI32_APITEST]
- Add tests for IS_TEXT_UNICODE_DBCS_LEADBYTE flag
[SDK]
- Add missed IS_TEXT_UNICODE_DBCS_LEADBYTE definition
Modified:
trunk/reactos/sdk/include/xdk/winnt_old.h
trunk/rostests/apitests/advapi32/IsTextUnicode.c
Modified: trunk/reactos/sdk/include/xdk/winnt_old.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/xdk/winnt_old.…
==============================================================================
--- trunk/reactos/sdk/include/xdk/winnt_old.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/include/xdk/winnt_old.h [iso-8859-1] Sun Aug 28 15:59:29 2016
@@ -915,6 +915,7 @@
#define IS_TEXT_UNICODE_REVERSE_SIGNATURE 128
#define IS_TEXT_UNICODE_ILLEGAL_CHARS 256
#define IS_TEXT_UNICODE_ODD_LENGTH 512
+#define IS_TEXT_UNICODE_DBCS_LEADBYTE 1024
#define IS_TEXT_UNICODE_NULL_BYTES 4096
#define IS_TEXT_UNICODE_UNICODE_MASK 15
#define IS_TEXT_UNICODE_REVERSE_MASK 240
Modified: trunk/rostests/apitests/advapi32/IsTextUnicode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/IsTextU…
==============================================================================
--- trunk/rostests/apitests/advapi32/IsTextUnicode.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/IsTextUnicode.c [iso-8859-1] Sun Aug 28 15:59:29
2016
@@ -8,7 +8,54 @@
#include <apitest.h>
#define WIN32_NO_STATUS
+#include <ndk/rtlfuncs.h>
#include <winbase.h>
+#include <winnls.h>
+#include <wincon.h>
+#include <stdio.h>
+
+PVOID LoadCodePageData(ULONG Code)
+{
+ char filename[MAX_PATH], sysdir[MAX_PATH];
+ HANDLE hFile;
+ PVOID Data = NULL;
+ GetSystemDirectoryA(sysdir, MAX_PATH);
+
+ if (Code != -1)
+ sprintf(filename, "%s\\c_%lu.nls", sysdir, Code);
+ else
+ sprintf(filename, "%s\\l_intl.nls", sysdir);
+
+ hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0,
NULL);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ DWORD dwRead;
+ DWORD dwFileSize = GetFileSize(hFile, NULL);
+ Data = malloc(dwFileSize);
+ ReadFile(hFile, Data, dwFileSize, &dwRead, NULL);
+ CloseHandle(hFile);
+ }
+ return Data;
+}
+
+/*
https://www.microsoft.com/resources/msdn/goglobal/default.mspx */
+void SetupLocale(ULONG AnsiCode, ULONG OemCode, ULONG Unicode)
+{
+ NLSTABLEINFO NlsTable;
+ PVOID AnsiCodePageData;
+ PVOID OemCodePageData;
+ PVOID UnicodeCaseTableData;
+
+ AnsiCodePageData = LoadCodePageData(AnsiCode);
+ OemCodePageData = LoadCodePageData(OemCode);
+ UnicodeCaseTableData = LoadCodePageData(Unicode);
+
+ RtlInitNlsTables(AnsiCodePageData, OemCodePageData, UnicodeCaseTableData,
&NlsTable);
+ RtlResetRtlTranslations(&NlsTable);
+ /* Do NOT free the buffers here, they are directly used!
+ Yes, we leak the old buffers, but this is a test anyway... */
+
+}
START_TEST(IsTextUnicode)
{
@@ -89,7 +136,15 @@
NEW_TEST(L"UNICODE S" L"\x0A0D" L"tring 5
ÐÑивеÑ!", IS_TEXT_UNICODE_ILLEGAL_CHARS, IS_TEXT_UNICODE_ILLEGAL_CHARS,
FALSE),
/* Unicode 0xFFFF */
NEW_TEST(L"UNICODE S" L"\xFFFF" L"tring 5
ÐÑивеÑ!", IS_TEXT_UNICODE_ILLEGAL_CHARS, IS_TEXT_UNICODE_ILLEGAL_CHARS,
FALSE),
+
+ // 35
+ NEW_TEST(L"UNICODE String 0", IS_TEXT_UNICODE_DBCS_LEADBYTE, 0, FALSE)
};
+
+ const char japanese_with_lead[] = "ABC" "\x83\x40"
"D";
+ const char simplfied_chinese_with_lead[] = "ABC" "\xC5\xC5"
"D";
+ const char korean_with_lead[] = "ABC" "\xBF\xAD" "D";
+ const char traditional_chinese_with_lead[] = "ABC" "\xB1\xC1"
"D";
UINT i;
BOOL Success;
@@ -103,4 +158,32 @@
if (Result != INVALID_FLAG)
ok(Result == Tests[i].ResultFlags, "IsTextUnicode(%u) Result returned
0x%x, expected 0x%x\n", i, Result, Tests[i].ResultFlags);
}
+
+ /* Japanese */
+ SetupLocale(932, 932, -1);
+
+ Result = IS_TEXT_UNICODE_DBCS_LEADBYTE;
+ ok(!IsTextUnicode(japanese_with_lead, sizeof(japanese_with_lead), &Result),
"IsTextUnicode() returned TRUE, expected FALSE\n");
+ ok(Result == IS_TEXT_UNICODE_DBCS_LEADBYTE, "Result returned 0x%x, expected
0x%x\n", Result, IS_TEXT_UNICODE_DBCS_LEADBYTE);
+
+ /* Simplified Chinese */
+ SetupLocale(936, 936, -1);
+
+ Result = IS_TEXT_UNICODE_DBCS_LEADBYTE;
+ ok(!IsTextUnicode(simplfied_chinese_with_lead, sizeof(simplfied_chinese_with_lead),
&Result), "IsTextUnicode() returned TRUE, expected FALSE\n");
+ ok(Result == IS_TEXT_UNICODE_DBCS_LEADBYTE, "Result returned 0x%x, expected
0x%x\n", Result, IS_TEXT_UNICODE_DBCS_LEADBYTE);
+
+ /* Korean */
+ SetupLocale(949, 949, -1);
+
+ Result = IS_TEXT_UNICODE_DBCS_LEADBYTE;
+ ok(!IsTextUnicode(korean_with_lead, sizeof(korean_with_lead), &Result),
"IsTextUnicode() returned TRUE, expected FALSE\n");
+ ok(Result == IS_TEXT_UNICODE_DBCS_LEADBYTE, "Result returned 0x%x, expected
0x%x\n", Result, IS_TEXT_UNICODE_DBCS_LEADBYTE);
+
+ /* Traditional Chinese */
+ SetupLocale(950, 950, -1);
+
+ Result = IS_TEXT_UNICODE_DBCS_LEADBYTE;
+ ok(!IsTextUnicode(traditional_chinese_with_lead,
sizeof(traditional_chinese_with_lead), &Result), "IsTextUnicode() returned TRUE,
expected FALSE\n");
+ ok(Result == IS_TEXT_UNICODE_DBCS_LEADBYTE, "Result returned 0x%x, expected
0x%x\n", Result, IS_TEXT_UNICODE_DBCS_LEADBYTE);
}