Something went wrong. Try again.
Reactos
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567/* * PROJECT: ReactOS api tests * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) * PURPOSE: Tests for i18n console. * COPYRIGHT: Copyright 2017-2020 Katayama Hirofumi MZ * Copyright 2020-2022 Hermès Bélusca-Maïto */
#include "precomp.h"
#define okCURSOR(hCon, c) \do { \ CONSOLE_SCREEN_BUFFER_INFO __sbi; \ BOOL expect = GetConsoleScreenBufferInfo((hCon), &__sbi) && \ __sbi.dwCursorPosition.X == (c).X && __sbi.dwCursorPosition.Y == (c).Y; \ ok(expect, "Expected cursor at (%d,%d), got (%d,%d)\n", \ (c).X, (c).Y, __sbi.dwCursorPosition.X, __sbi.dwCursorPosition.Y); \} while (0)
#define ATTR (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED)
static const WCHAR u0414[] = {0x0414, 0}; /* Д */static const WCHAR u9580[] = {0x9580, 0}; /* 門 */static const WCHAR space[] = {L' ', 0};static const WCHAR ideograph_space = (WCHAR)0x3000; /* fullwidth space */static const WCHAR s_str[] = {L'A', 0x9580, 'B', 0};static const LCID lcidJapanese = MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT);static const LCID lcidRussian = MAKELCID(MAKELANGID(LANG_RUSSIAN , SUBLANG_DEFAULT), SORT_DEFAULT);
static UINT s_uOEMCP;static BOOL s_bIs8Plus;
static BOOL IsCJKCodePage(_In_ UINT CodePage){ switch (CodePage) { case 932: // Japanese case 949: // Korean case 1361: // Korean (Johab) case 936: // Chinese PRC case 950: // Taiwan return TRUE; } return FALSE;}
static __inlineLANGID MapCJKCPToLangId(_In_ UINT CodePage){ switch (CodePage) { case 932: // Japanese (Shift-JIS) return MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT); case 949: // Korean (Hangul/Wansung) // case 1361: // Korean (Johab) return MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN); case 936: // Chinese PRC (Chinese Simplified) return MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED); case 950: // Taiwan (Chinese Traditional) return MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL); default: return MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); }}
static BOOL ChangeOutputCP_( _In_ const char* file, _In_ int line, _In_ UINT CodePage){ BOOL bSuccess;
/* Validate the code page */ bSuccess = IsValidCodePage(CodePage); if (!bSuccess) { skip_(file, line)("Code page %d not available\n", CodePage); return FALSE; }
/* Set the new code page */ SetLastError(0xdeadbeef); bSuccess = SetConsoleOutputCP(CodePage); if (!bSuccess) skip_(file, line)("SetConsoleOutputCP(%d) failed with last error %lu\n", CodePage, GetLastError()); return bSuccess;}
#define ChangeOutputCP(CodePage) \ ChangeOutputCP_(__FILE__, __LINE__, CodePage)
#define cmpThreadLangId(file, line, ExpectedLangId) \do { \ LANGID ThreadLangId; \ ThreadLangId = LANGIDFROMLCID(NtCurrentTeb()->CurrentLocale); \ trace_((file), (line))("Thread LangId %d, expecting %d...\n", \ ThreadLangId, (ExpectedLangId)); \ ok_((file), (line))(ThreadLangId == (ExpectedLangId), \ "Thread LangId %d, expected %d\n", \ ThreadLangId, (ExpectedLangId)); \} while (0)
static BOOLdoTest_CP_ThreadLang_( _In_ const char* file, _In_ int line, _In_ UINT CodePage, _In_ LANGID ExpectedLangId){ UINT newcp;
/* Verify and set the new code page */ if (!ChangeOutputCP_(file, line, CodePage)) { skip_(file, line)("Code page %d expected to be valid!\n", CodePage); return FALSE; }
newcp = GetConsoleOutputCP(); ok_(file, line)(newcp == CodePage, "Console output CP is %d, expected %d\n", newcp, CodePage);
/* Verify that the thread lang ID is the expected one */ cmpThreadLangId(file, line, ExpectedLangId); return TRUE;}
#define doTest_CP_ThreadLang(...) \ doTest_CP_ThreadLang_(__FILE__, __LINE__, ##__VA_ARGS__)
static VOID test_CP_ThreadLang(VOID){ /* Save the initial current thread locale. It is (re)initialized after * attaching to a console. Don't use GetThreadLocale() as the latter * can return a replacement value in case CurrentLocale is 0. */ LANGID ThreadLangId = LANGIDFROMLCID(NtCurrentTeb()->CurrentLocale); UINT oldcp = GetConsoleOutputCP();
if (IsCJKCodePage(s_uOEMCP)) { /* We are on a CJK system */
/* Is the console in CJK? If so, current thread should be in CJK language */ if (!IsCJKCodePage(oldcp)) { skip("CJK system but console CP not in CJK\n"); } else { /* Check that the thread lang ID matches what the console set */ LANGID LangId = MapCJKCPToLangId(oldcp); cmpThreadLangId(__FILE__, __LINE__, LangId); }
/* Set the code page to OEM USA (non-CJK codepage that is supported). * Verify that the thread lang ID has changed to non-CJK language. */ doTest_CP_ThreadLang(437, MapCJKCPToLangId(437));
/* Set the code page to the default system CJK codepage. * Check that the thread lang ID matches what the console set. */ doTest_CP_ThreadLang(s_uOEMCP, MapCJKCPToLangId(s_uOEMCP)); } else { /* We are on a non-CJK system */
/* Code pages: Japanese, Korean, Chinese Simplified/Traditional */ UINT CJKCodePages[] = {932, 949, 936, 950}; UINT newcp; USHORT i;
/* Switch to a different code page (OEM USA) than the current one. * In such setup, the current thread lang ID should not change. */ newcp = (s_uOEMCP == 437 ? 850 : 437); doTest_CP_ThreadLang(newcp, ThreadLangId);
/* Try switching to a CJK codepage, if possible, but * the thread lang ID should not change either... */
/* Retry as long as no valid CJK codepage has been found */ for (i = 0; i < ARRAYSIZE(CJKCodePages); ++i) { newcp = CJKCodePages[i]; if (IsValidCodePage(newcp)) break; // Found a valid one. } if (i >= ARRAYSIZE(CJKCodePages)) { /* No valid CJK code pages on the system */ skip("CJK system but console CP not in CJK\n"); } else { /* Verify that the thread lang ID remains the same */ doTest_CP_ThreadLang(newcp, ThreadLangId); } }
/* Restore code page */ SetConsoleOutputCP(oldcp);}
/* Russian Code Page 855 */// NOTE that CP 866 can also be usedstatic void test_cp855(HANDLE hConOut){ BOOL ret; UINT oldcp; int n; DWORD len; COORD c; CONSOLE_SCREEN_BUFFER_INFO csbi; int count; WCHAR str[32]; WORD attrs[16];
/* Set code page */ oldcp = GetConsoleOutputCP(); if (!ChangeOutputCP(855)) { skip("Codepage 855 not available\n"); return; }
/* Get info */ ret = GetConsoleScreenBufferInfo(hConOut, &csbi); ok(ret, "GetConsoleScreenBufferInfo failed\n"); trace("csbi.dwSize.X:%d, csbi.dwSize.Y:%d\n", csbi.dwSize.X, csbi.dwSize.Y); count = 200;
/* "\u0414" */ { /* Output u0414 "count" times at (0,0) */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u0414, lstrlenW(u0414), &len, NULL); ok(ret && len == lstrlenW(u0414), "WriteConsoleW failed\n"); }
/* Check cursor */ len = count; /* u0414 is normal width in Russian */ c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Read characters at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 6); ok_int(str[0], 0x414); ok_int(str[1], 0x414); ok_int(str[2], 0x414);
/* Read attributes at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 6, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 6); ok_int(attrs[0], ATTR);
/* Check cursor */ c.X = 1; c.Y = 0; ret = SetConsoleCursorPosition(hConOut, c); ok(ret, "SetConsoleCursorPosition failed\n"); okCURSOR(hConOut, c);
/* Fill by space */ c.X = c.Y = 0; FillConsoleOutputCharacterW(hConOut, L' ', csbi.dwSize.X * csbi.dwSize.Y, c, &len);
/* Output u0414 "count" times at (1,0) */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u0414, lstrlenW(u0414), &len, NULL); ok(ret && len == lstrlenW(u0414), "WriteConsoleW failed\n"); }
/* Check cursor */ len = 1 + count; c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Read characters at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 6); ok_int(str[0], L' '); ok_int(str[1], 0x414); ok_int(str[2], 0x414); }
/* "\u9580" */ { /* Output u9580 "count" times at (0,0) */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u9580, lstrlenW(u9580), &len, NULL); ok(ret && len == lstrlenW(u9580), "WriteConsoleW failed\n"); }
/* Check cursor */ len = count; /* u9580 is normal width in Russian */ c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Check cursor */ c.X = 1; c.Y = 0; ret = SetConsoleCursorPosition(hConOut, c); ok(ret, "SetConsoleCursorPosition failed\n"); okCURSOR(hConOut, c);
/* Fill by space */ c.X = c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, L' ', csbi.dwSize.X * csbi.dwSize.Y, c, &len); ok(ret, "FillConsoleOutputCharacterW failed\n"); ok_long(len, csbi.dwSize.X * csbi.dwSize.Y);
/* Output u9580 "count" times at (1,0) */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u9580, lstrlenW(u9580), &len, NULL); ok(ret && len == lstrlenW(u9580), "WriteConsoleW failed\n"); }
/* Check cursor */ len = 1 + count; c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Fill by ideograph space */ c.X = c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, ideograph_space, csbi.dwSize.X * csbi.dwSize.Y, c, &len); ok(ret, "FillConsoleOutputCharacterW failed\n"); ok_long(len, csbi.dwSize.X * csbi.dwSize.Y);
/* Read characters at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 6); ok(str[0] == ideograph_space || str[0] == L'?', "str[0] was: 0x%04X\n", str[0]); ok(str[1] == ideograph_space || str[1] == L'?', "str[1] was: 0x%04X\n", str[1]); ok(str[2] == ideograph_space || str[2] == L'?', "str[2] was: 0x%04X\n", str[2]);
/* Read attributes at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 6, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 6); ok_int(attrs[0], ATTR);
/* Read characters at (1,0) */ c.X = 1; c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 6); ok(str[0] == ideograph_space || str[0] == L'?', "str[0] was: 0x%04X\n", str[0]); ok(str[1] == ideograph_space || str[1] == L'?', "str[1] was: 0x%04X\n", str[1]); ok(str[2] == ideograph_space || str[2] == L'?', "str[2] was: 0x%04X\n", str[2]);
/* Output u9580 "count" once at (1,0) */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); ret = WriteConsoleW(hConOut, u9580, lstrlenW(u9580), &len, NULL); ok(ret && len == lstrlenW(u9580), "WriteConsoleW failed\n");
/* Read attributes at (1,0) */ c.X = 1; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 1, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 1); ok_int(attrs[0], ATTR);
/* Check cursor */ c.X = 2; c.Y = 0; okCURSOR(hConOut, c);
/* Read characters at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 6); ok(str[0] == ideograph_space || str[0] == L'?', "str[0] was: 0x%04X\n", str[0]); ok(str[1] == u9580[0] || str[1] == L'?', "str[1] was: 0x%04X\n", str[1]); ok(str[2] == ideograph_space || str[2] == L'?', "str[2] was: 0x%04X\n", str[2]); }
/* Restore code page */ SetConsoleOutputCP(oldcp);}
/* Japanese Code Page 932 */static void test_cp932(HANDLE hConOut){ BOOL ret; UINT oldcp; int n; DWORD len; COORD c, buffSize; CONSOLE_SCREEN_BUFFER_INFO csbi; int count; WCHAR str[32]; WORD attrs[16]; CHAR_INFO buff[16]; SMALL_RECT sr;
/* Set code page */ oldcp = GetConsoleOutputCP(); if (!ChangeOutputCP(932)) { skip("Codepage 932 not available\n"); return; }
/* Get info */ ret = GetConsoleScreenBufferInfo(hConOut, &csbi); ok(ret, "GetConsoleScreenBufferInfo failed\n"); trace("csbi.dwSize.X:%d, csbi.dwSize.Y:%d\n", csbi.dwSize.X, csbi.dwSize.Y); count = 200;
/* "\u0414" */ { /* Output u0414 "count" times at (0,0) */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u0414, lstrlenW(u0414), &len, NULL); ok(ret && len == lstrlenW(u0414), "WriteConsoleW failed\n"); }
/* Check cursor */ GetConsoleScreenBufferInfo(hConOut, &csbi); len = count * 2; /* u0414 is fullwidth in Japanese */ c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Read characters at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 3); ok_int(str[0], 0x414); ok_int(str[1], 0x414); ok_int(str[2], 0x414);
/* Read attributes at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 6, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 6); ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE);
/* Check cursor */ c.X = 1; c.Y = 0; ret = SetConsoleCursorPosition(hConOut, c); ok(ret, "SetConsoleCursorPosition failed\n"); okCURSOR(hConOut, c);
/* Fill by space */ c.X = c.Y = 0; FillConsoleOutputCharacterW(hConOut, L' ', csbi.dwSize.X * csbi.dwSize.Y, c, &len);
/* Output u0414 "count" times at (1,0) */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u0414, lstrlenW(u0414), &len, NULL); ok(ret && len == lstrlenW(u0414), "WriteConsoleW failed\n"); }
/* Check cursor */ len = csbi.dwSize.X + (count - (csbi.dwSize.X - 1) / 2) * 2; c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Read characters at (0,0) */ c.X = 0; c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 4); ok_int(str[0], L' '); ok_int(str[1], 0x414); ok_int(str[2], 0x414); }
/* "\u9580" */ { /* Output u9580 "count" times at (0,0) */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u9580, lstrlenW(u9580), &len, NULL); ok(ret && len == lstrlenW(u9580), "WriteConsoleW failed\n"); }
/* Check cursor */ len = count * 2; /* u9580 is fullwidth in Japanese */ c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Check cursor */ c.X = 1; c.Y = 0; ret = SetConsoleCursorPosition(hConOut, c); ok(ret, "SetConsoleCursorPosition failed\n"); okCURSOR(hConOut, c);
/* Fill by space */ c.X = c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, L' ', csbi.dwSize.X * csbi.dwSize.Y, c, &len); ok(ret, "FillConsoleOutputCharacterW failed\n"); ok_long(len, csbi.dwSize.X * csbi.dwSize.Y);
/* Output u9580 "count" times at (1,0) */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, u9580, lstrlenW(u9580), &len, NULL); ok(ret && len == lstrlenW(u9580), "WriteConsoleW failed\n"); }
/* Check cursor */ len = csbi.dwSize.X + (count - (csbi.dwSize.X - 1) / 2) * 2; c.X = (SHORT)(len % csbi.dwSize.X); c.Y = (SHORT)(len / csbi.dwSize.X); okCURSOR(hConOut, c);
/* Fill by ideograph space */ c.X = c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, ideograph_space, csbi.dwSize.X * csbi.dwSize.Y, c, &len); ok(ret, "FillConsoleOutputCharacterW failed\n"); if (s_bIs8Plus) ok_long(len, csbi.dwSize.X * csbi.dwSize.Y / 2); else ok_long(len, csbi.dwSize.X * csbi.dwSize.Y);
/* Read characters at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); ok_long(len, 3); ok_int(str[0], ideograph_space); ok_int(str[1], ideograph_space); ok_int(str[2], ideograph_space);
/* Read attributes at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 6, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 6); ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[3], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[4], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[5], ATTR | COMMON_LVB_TRAILING_BYTE);
/* Output u9580 "count" once at (1,0) */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); ret = WriteConsoleW(hConOut, u9580, lstrlenW(u9580), &len, NULL); ok(ret && len == lstrlenW(u9580), "WriteConsoleW failed\n");
/* * Read attributes at (1,0) - * Note that if only one attribute of a fullwidth character * is retrieved, no leading/trailing byte flag is set! */ c.X = 1; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 1, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 1); ok_int(attrs[0], ATTR);
/* Check that the same problem happens for the trailing byte */ c.X = 2; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 1, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 1); ok_int(attrs[0], ATTR);
/* Read attributes at (1,0) */ c.X = 1; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 2, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 2); ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE);
/* Read attributes at (1,0) */ ret = ReadConsoleOutputAttribute(hConOut, attrs, 3, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 3); ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE); if (s_bIs8Plus) ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); else ok_int(attrs[2], ATTR);
/* Read attributes at (0,0) */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 4, c, &len); ok(ret, "ReadConsoleOutputAttribute failed\n"); ok_long(len, 4); if (s_bIs8Plus) ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); else ok_int(attrs[0], ATTR); ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); if (s_bIs8Plus) ok_int(attrs[3], ATTR | COMMON_LVB_TRAILING_BYTE); else ok_int(attrs[3], ATTR);
/* Check cursor */ c.X = 3; c.Y = 0; okCURSOR(hConOut, c);
/* Read characters */ c.X = c.Y = 0; ret = ReadConsoleOutputCharacterW(hConOut, str, 3 * sizeof(WCHAR), c, &len); ok(ret, "ReadConsoleOutputCharacterW failed\n"); if (s_bIs8Plus) { ok_long(len, 3); ok_int(str[0], ideograph_space); ok_int(str[1], u9580[0]); ok_int(str[2], ideograph_space); } else { ok_long(len, 4); ok_int(str[0], L' '); ok_int(str[1], u9580[0]); ok_int(str[2], L' '); } }
/* COMMON_LVB_LEADING_BYTE and COMMON_LVB_TRAILING_BYTE for u0414 */ { /* set cursor */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* fill by 'A' */ ret = FillConsoleOutputCharacterW(hConOut, L'A', csbi.dwSize.X * 2, c, &len); ok_int(ret, 1); ok_long(len, csbi.dwSize.X * 2);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; ZeroMemory(&sr, sizeof(sr)); sr.Right = buffSize.X - 1; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, buffSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ ok_int(buff[0].Char.UnicodeChar, L'A'); ok_int(buff[0].Attributes, ATTR);
/* read attr */ ret = ReadConsoleOutputAttribute(hConOut, attrs, 1, c, &len); ok_int(ret, 1); ok_long(len, 1); ok_int(attrs[0], ATTR);
/* read char */ c.X = c.Y = 0; memset(str, 0x7F, sizeof(str)); ret = ReadConsoleOutputCharacterW(hConOut, str, 4, c, &len); ok_int(ret, 1); ok_long(len, 4); ok_int(str[0], L'A'); ok_int(str[1], L'A'); ok_int(str[2], L'A'); ok_int(str[3], L'A');
/* set cursor */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* write u0414 */ ret = WriteConsoleW(hConOut, u0414, 1, &len, NULL); ok_int(ret, 1); ok_long(len, 1);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; ZeroMemory(&sr, sizeof(sr)); sr.Right = buffSize.X - 1; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, buffSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ if (s_bIs8Plus) { ok_int(buff[0].Char.UnicodeChar, 0x0414); ok_int(buff[0].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[1].Char.UnicodeChar, 0x0414); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(buff[0].Char.UnicodeChar, 0x0414); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, L'A'); ok_int(buff[1].Attributes, ATTR); } ok_int(buff[2].Char.UnicodeChar, L'A'); ok_int(buff[2].Attributes, ATTR); ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR);
/* read attr */ ret = ReadConsoleOutputAttribute(hConOut, attrs, ARRAYSIZE(attrs), c, &len); ok_int(ret, 1); ok_long(len, ARRAYSIZE(attrs)); ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[2], ATTR); ok_int(attrs[3], ATTR);
/* read char */ c.X = c.Y = 0; memset(str, 0x7F, sizeof(str)); ret = ReadConsoleOutputCharacterW(hConOut, str, 4, c, &len); ok_int(ret, 1); ok_long(len, 3); ok_int(str[0], 0x0414); ok_int(str[1], L'A'); ok_int(str[2], L'A'); if (s_bIs8Plus) ok_int(str[3], 0); else ok_int(str[3], 0x7F7F);
/* set cursor */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* write u0414 */ ret = WriteConsoleW(hConOut, u0414, 1, &len, NULL); ok_int(ret, 1); ok_long(len, 1);
/* read output */ c.X = c.Y = 0; ZeroMemory(&sr, sizeof(sr)); sr.Right = buffSize.X - 1; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, buffSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ if (s_bIs8Plus) { ok_int(buff[0].Char.UnicodeChar, 0x0414); ok_int(buff[0].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[1].Char.UnicodeChar, 0x0414); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[2].Char.UnicodeChar, 0x0414); ok_int(buff[2].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(buff[0].Char.UnicodeChar, L' '); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, 0x0414); ok_int(buff[1].Attributes, ATTR); ok_int(buff[2].Char.UnicodeChar, L'A'); ok_int(buff[2].Attributes, ATTR); } ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR);
/* read attr */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, ARRAYSIZE(attrs), c, &len); ok_int(ret, 1); ok_long(len, ARRAYSIZE(attrs)); if (s_bIs8Plus) ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); else ok_int(attrs[0], ATTR); ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[3], ATTR);
/* read char */ c.X = c.Y = 0; memset(str, 0x7F, sizeof(str)); ret = ReadConsoleOutputCharacterW(hConOut, str, 4, c, &len); ok_int(ret, 1); ok_long(len, 3); if (s_bIs8Plus) { ok_int(str[0], 0x0414); ok_int(str[1], 0x0414); ok_int(str[2], L'A'); ok_int(str[3], 0); } else { ok_int(str[0], L' '); ok_int(str[1], 0x0414); ok_int(str[2], L'A'); ok_int(str[3], 0x7F7F); }
/* set cursor */ c.X = csbi.dwSize.X - 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* write u0414 */ WriteConsoleW(hConOut, u0414, 1, &len, NULL); ok_int(ret, 1); ok_long(len, 1);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; sr.Left = csbi.dwSize.X - 2; sr.Top = 0; sr.Right = csbi.dwSize.X - 1; sr.Bottom = 0; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, csbi.dwSize.X - 2); ok_int(sr.Top, 0); ok_int(sr.Right, csbi.dwSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ ok_int(buff[0].Char.UnicodeChar, L'A'); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, L'A'); ok_int(buff[1].Attributes, ATTR);
/* read attrs */ c.X = csbi.dwSize.X - 2; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, ARRAYSIZE(attrs), c, &len); ok_int(ret, 1); ok_long(len, ARRAYSIZE(attrs)); ok_int(attrs[0], ATTR); ok_int(attrs[1], ATTR);
/* read char */ ret = ReadConsoleOutputCharacterW(hConOut, str, 2, c, &len); ok_int(ret, 1); ok_long(len, 2); ok_int(str[0], L'A'); ok_int(str[1], L'A');
/* fill by 'A' */ c.X = c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, L'A', 10, c, &len); ok_int(ret, 1); ok_long(len, 10);
/* fill by u0414 */ c.X = 1; c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, 0x0414, 1, c, &len); c.X = c.Y = 0; ok_int(ret, 1); ok_long(len, 1);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; sr.Left = 0; sr.Top = 0; sr.Right = 4; sr.Bottom = 0; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, 4); ok_int(sr.Bottom, 0);
/* check buff */ ok_int(buff[0].Char.UnicodeChar, L'A'); ok_int(buff[0].Attributes, ATTR); if (s_bIs8Plus) { ok_int(buff[1].Char.UnicodeChar, 0x0414); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[2].Char.UnicodeChar, 0x0414); ok_int(buff[2].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(buff[1].Char.UnicodeChar, L' '); ok_int(buff[1].Attributes, ATTR); ok_int(buff[2].Char.UnicodeChar, L'A'); ok_int(buff[2].Attributes, ATTR); } ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR); ok_int(buff[4].Char.UnicodeChar, L'A'); ok_int(buff[4].Attributes, ATTR);
/* read attrs */ c.X = 0; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 4, c, &len); ok_int(ret, 1); ok_long(len, 4); ok_int(attrs[0], ATTR); if (s_bIs8Plus) { ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(attrs[1], ATTR); ok_int(attrs[2], ATTR); } ok_int(attrs[3], ATTR); }
/* COMMON_LVB_LEADING_BYTE and COMMON_LVB_TRAILING_BYTE for u9580 */ { /* set cursor */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* fill by 'A' */ ret = FillConsoleOutputCharacterW(hConOut, L'A', csbi.dwSize.X * 2, c, &len); ok_int(ret, 1); ok_long(len, csbi.dwSize.X * 2);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; ZeroMemory(&sr, sizeof(sr)); sr.Right = buffSize.X - 1; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, buffSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ ok_int(buff[0].Char.UnicodeChar, L'A'); ok_int(buff[0].Attributes, ATTR);
/* read attr */ ret = ReadConsoleOutputAttribute(hConOut, attrs, 1, c, &len); ok_int(ret, 1); ok_long(len, 1); ok_int(attrs[0], ATTR);
/* read char */ memset(str, 0x7F, sizeof(str)); ret = ReadConsoleOutputCharacterW(hConOut, str, 2, c, &len); ok_int(ret, 1); ok_long(len, 2); ok_int(str[0], L'A'); ok_int(str[1], L'A');
/* set cursor */ c.X = 0; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* write u9580 */ ret = WriteConsoleW(hConOut, u9580, 1, &len, NULL); ok_int(ret, 1); ok_long(len, 1);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; ZeroMemory(&sr, sizeof(sr)); sr.Right = buffSize.X - 1; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, buffSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ if (s_bIs8Plus) { ok_int(buff[0].Char.UnicodeChar, u9580[0]); ok_int(buff[0].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[1].Char.UnicodeChar, u9580[0]); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(buff[0].Char.UnicodeChar, u9580[0]); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, L'A'); ok_int(buff[1].Attributes, ATTR); } ok_int(buff[2].Char.UnicodeChar, L'A'); ok_int(buff[2].Attributes, ATTR); ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR);
/* read attr */ ret = ReadConsoleOutputAttribute(hConOut, attrs, ARRAYSIZE(attrs), c, &len); ok_int(ret, 1); ok_long(len, ARRAYSIZE(attrs));
ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[2], ATTR); ok_int(attrs[3], ATTR);
/* read char */ c.X = c.Y = 0; memset(str, 0x7F, sizeof(str)); ret = ReadConsoleOutputCharacterW(hConOut, str, 4, c, &len); ok_int(ret, 1); ok_long(len, 3); ok_int(str[0], u9580[0]); ok_int(str[1], L'A'); ok_int(str[2], L'A'); if (s_bIs8Plus) ok_int(str[3], 0); else ok_int(str[3], 0x7F7F);
/* set cursor */ c.X = 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* write u9580 */ ret = WriteConsoleW(hConOut, u9580, 1, &len, NULL); ok_int(ret, 1); ok_long(len, 1);
/* read output */ c.X = c.Y = 0; ZeroMemory(&sr, sizeof(sr)); sr.Right = buffSize.X - 1; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, buffSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ if (s_bIs8Plus) { ok_int(buff[0].Char.UnicodeChar, u9580[0]); ok_int(buff[0].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[1].Char.UnicodeChar, u9580[0]); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[2].Char.UnicodeChar, u9580[0]); ok_int(buff[2].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(buff[0].Char.UnicodeChar, L' '); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, u9580[0]); ok_int(buff[1].Attributes, ATTR); ok_int(buff[2].Char.UnicodeChar, L'A'); ok_int(buff[2].Attributes, ATTR); } ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR);
/* read attr */ c.X = c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, ARRAYSIZE(attrs), c, &len); ok_int(ret, 1); ok_long(len, ARRAYSIZE(attrs));
if (s_bIs8Plus) { ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); } else { ok_int(attrs[0], ATTR); } ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[3], ATTR);
/* set cursor */ c.X = csbi.dwSize.X - 1; c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c);
/* write u9580 */ WriteConsoleW(hConOut, u9580, 1, &len, NULL); ok_int(ret, 1); ok_long(len, 1);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; sr.Left = csbi.dwSize.X - 2; sr.Top = 0; sr.Right = csbi.dwSize.X - 1; sr.Bottom = 0; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, csbi.dwSize.X - 2); ok_int(sr.Top, 0); ok_int(sr.Right, csbi.dwSize.X - 1); ok_int(sr.Bottom, 0);
/* check buff */ ok_int(buff[0].Char.UnicodeChar, L'A'); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, L'A'); ok_int(buff[1].Attributes, ATTR);
/* read attr */ c.X = csbi.dwSize.X - 2; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, ARRAYSIZE(attrs), c, &len); ok_int(ret, 1); ok_long(len, ARRAYSIZE(attrs)); ok_int(attrs[0], ATTR); ok_int(attrs[1], ATTR);
/* read char */ memset(str, 0x7F, sizeof(str)); ret = ReadConsoleOutputCharacterW(hConOut, str, 2, c, &len); ok_int(ret, 1); ok_long(len, 2); ok_int(str[0], L'A'); ok_int(str[1], L'A');
/* fill by 'A' */ c.X = c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, L'A', 10, c, &len); ok_int(ret, 1); ok_long(len, 10);
/* fill by u9580 */ c.X = 1; c.Y = 0; ret = FillConsoleOutputCharacterW(hConOut, u9580[0], 1, c, &len); c.X = c.Y = 0; ok_int(ret, 1); ok_long(len, 1);
/* reset buff */ buffSize.X = ARRAYSIZE(buff); buffSize.Y = 1; memset(buff, 0x7F, sizeof(buff));
/* read output */ c.X = c.Y = 0; sr.Left = 0; sr.Top = 0; sr.Right = 4; sr.Bottom = 0; ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, 4); ok_int(sr.Bottom, 0);
/* check buff */ ok_int(buff[0].Char.UnicodeChar, L'A'); ok_int(buff[0].Attributes, ATTR); if (s_bIs8Plus) { ok_int(buff[1].Char.UnicodeChar, u9580[0]); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[2].Char.UnicodeChar, u9580[0]); ok_int(buff[2].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(buff[1].Char.UnicodeChar, L' '); ok_int(buff[1].Attributes, ATTR); ok_int(buff[2].Char.UnicodeChar, L'A'); ok_int(buff[2].Attributes, ATTR); } ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR); ok_int(buff[4].Char.UnicodeChar, L'A'); ok_int(buff[4].Attributes, ATTR);
/* read attrs */ c.X = 0; c.Y = 0; ret = ReadConsoleOutputAttribute(hConOut, attrs, 4, c, &len); ok_int(ret, 1); ok_long(len, 4); ok_int(attrs[0], ATTR); if (s_bIs8Plus) { ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); } else { ok_int(attrs[1], ATTR); ok_int(attrs[2], ATTR); } ok_int(attrs[3], ATTR); }
/* FillConsoleOutputAttribute and WriteConsoleOutput */ { c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, space, lstrlenW(space), &len, NULL); ok_int(ret, 1); ok_long(len, 1); }
/* fill attrs */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); ret = FillConsoleOutputAttribute(hConOut, 0xFFFF, 2, c, &len); ok_int(ret, 1); ok_long(len, 2);
/* read attrs */ memset(attrs, 0x7F, sizeof(attrs)); ret = ReadConsoleOutputAttribute(hConOut, attrs, 3, c, &len); ok_int(ret, 1); ok_long(len, 3); if (s_bIs8Plus) { ok_int(attrs[0], 0xDCFF); ok_int(attrs[1], 0xDCFF); } else { ok_int(attrs[0], 0xFCFF); ok_int(attrs[1], 0xFCFF); } ok_int(attrs[2], ATTR);
/* fill attrs */ c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); ret = FillConsoleOutputAttribute(hConOut, ATTR, 4, c, &len); ok_int(ret, 1); ok_long(len, 4);
/* write */ c.X = c.Y = 0; sr.Left = 0; sr.Top = 0; sr.Right = 4; sr.Bottom = 0; // Check how Read/WriteConsoleOutput() handle inconsistent DBCS flags. buff[0].Char.UnicodeChar = u9580[0]; buff[0].Attributes = ATTR | COMMON_LVB_LEADING_BYTE; buff[1].Char.UnicodeChar = u9580[0]; buff[1].Attributes = ATTR | COMMON_LVB_LEADING_BYTE; buff[2].Char.UnicodeChar = u9580[0]; buff[2].Attributes = ATTR | COMMON_LVB_TRAILING_BYTE; buff[3].Char.UnicodeChar = L'A'; buff[3].Attributes = ATTR; buff[4].Char.UnicodeChar = L' '; buff[4].Attributes = 0xFFFF; buffSize.X = 4; buffSize.Y = 1; ret = WriteConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, 3); ok_int(sr.Bottom, 0);
/* read output */ sr.Left = 0; sr.Top = 0; sr.Right = 4; sr.Bottom = 0; memset(buff, 0x7F, sizeof(buff)); ret = ReadConsoleOutputW(hConOut, buff, buffSize, c, &sr); ok_int(ret, 1); ok_int(sr.Left, 0); ok_int(sr.Top, 0); ok_int(sr.Right, 3); ok_int(sr.Bottom, 0);
/* check buff */ if (s_bIs8Plus) { ok_int(buff[0].Char.UnicodeChar, u9580[0]); ok_int(buff[0].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[1].Char.UnicodeChar, u9580[0]); ok_int(buff[1].Attributes, ATTR | COMMON_LVB_LEADING_BYTE); ok_int(buff[2].Char.UnicodeChar, u9580[0]); ok_int(buff[2].Attributes, ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(buff[3].Char.UnicodeChar, L'A'); ok_int(buff[3].Attributes, ATTR); ok_int(buff[4].Char.UnicodeChar, 0x7F7F); ok_int(buff[4].Attributes, 0x7F7F); } else { ok_int(buff[0].Char.UnicodeChar, u9580[0]); ok_int(buff[0].Attributes, ATTR); ok_int(buff[1].Char.UnicodeChar, u9580[0]); ok_int(buff[1].Attributes, ATTR); ok_int(buff[2].Char.UnicodeChar, 0); ok_int(buff[2].Attributes, 0); ok_int(buff[3].Char.UnicodeChar, 0); ok_int(buff[3].Attributes, 0); ok_int(buff[4].Char.UnicodeChar, 0x7F7F); ok_int(buff[4].Attributes, 0x7F7F); }
/* read attrs */ c.X = c.Y = 0; memset(attrs, 0x7F, sizeof(attrs)); ret = ReadConsoleOutputAttribute(hConOut, attrs, 6, c, &len); ok_int(ret, 1); ok_long(len, 6); ok_int(attrs[0], ATTR | COMMON_LVB_LEADING_BYTE); if (s_bIs8Plus) { ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[3], ATTR); } else { ok_int(attrs[1], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[3], ATTR | COMMON_LVB_TRAILING_BYTE); } ok_int(attrs[4], ATTR); ok_int(attrs[5], ATTR); }
/* WriteConsoleOutputCharacterW and WriteConsoleOutputAttribute */ { c.X = c.Y = 0; SetConsoleCursorPosition(hConOut, c); okCURSOR(hConOut, c); for (n = 0; n < count; ++n) { ret = WriteConsoleW(hConOut, space, lstrlenW(space), &len, NULL); ok_int(ret, 1); ok_long(len, 1); }
/* write attrs */ attrs[0] = ATTR; attrs[1] = 0xFFFF; attrs[2] = ATTR; attrs[3] = 0; ret = WriteConsoleOutputAttribute(hConOut, attrs, 4, c, &len); ok_int(ret, 1); ok_long(len, 4);
/* read attrs */ memset(attrs, 0x7F, sizeof(attrs)); ret = ReadConsoleOutputAttribute(hConOut, attrs, 4, c, &len); ok_int(ret, 1); ok_long(len, 4); ok_int(attrs[0], ATTR); if (s_bIs8Plus) ok_int(attrs[1], 0xDCFF); else ok_int(attrs[1], 0xFCFF); ok_int(attrs[2], ATTR); ok_int(attrs[3], 0);
/* fill attr */ ret = FillConsoleOutputAttribute(hConOut, ATTR, 4, c, &len); ok_int(ret, 1); ok_long(len, 4);
/* write char */ ret = WriteConsoleOutputCharacterW(hConOut, s_str, 4, c, &len); ok_int(ret, 1); ok_long(len, 4);
/* read attrs */ memset(attrs, 0x7F, sizeof(attrs)); ret = ReadConsoleOutputAttribute(hConOut, attrs, 4, c, &len); ok_int(ret, 1); ok_long(len, 4); ok_int(attrs[0], ATTR); ok_int(attrs[1], ATTR | COMMON_LVB_LEADING_BYTE); ok_int(attrs[2], ATTR | COMMON_LVB_TRAILING_BYTE); ok_int(attrs[3], ATTR); }
/* Restore code page */ SetConsoleOutputCP(oldcp);}
START_TEST(ConsoleCP){ HANDLE hConIn, hConOut; OSVERSIONINFOA osver = { sizeof(osver) };
// https://github.com/reactos/reactos/pull/2131#issuecomment-563189380 GetVersionExA(&osver); s_bIs8Plus = (osver.dwMajorVersion > 6) || (osver.dwMajorVersion == 6 && osver.dwMinorVersion >= 2);
FreeConsole(); ok(AllocConsole(), "Couldn't alloc console\n");
hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n"); ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
/* Retrieve the system OEM code page */ s_uOEMCP = GetOEMCP(); trace("Running on %s system (codepage %d)\n", IsCJKCodePage(s_uOEMCP) ? "CJK" : "Non-CJK", s_uOEMCP);
/* Test thread lang ID syncing with console code page */ test_CP_ThreadLang();
if (IsValidLocale(lcidRussian, LCID_INSTALLED)) { if (!IsCJKCodePage(s_uOEMCP)) test_cp855(hConOut); else skip("Russian testcase is skipped because of CJK\n"); } else { skip("Russian locale is not installed\n"); }
if (IsValidLocale(lcidJapanese, LCID_INSTALLED)) { if (IsCJKCodePage(s_uOEMCP)) test_cp932(hConOut); else skip("Japanese testcase is skipped because of not CJK\n"); } else { skip("Japanese locale is not installed\n"); }
CloseHandle(hConIn); CloseHandle(hConOut); FreeConsole(); ok(AllocConsole(), "Couldn't alloc console\n");}