ReactOS 0.4.15-dev-7788-g1ad9096
StrFormatByteSizeW.c File Reference
#include <apitest.h>
#include <shlwapi.h>
#include <strsafe.h>
Include dependency graph for StrFormatByteSizeW.c:

Go to the source code of this file.

Macros

#define DO_TEST(exp, str)
 

Functions

static BOOL is_lang_english (void)
 
static BOOL is_locale_english (void)
 
 START_TEST (StrFormatByteSizeW)
 

Variables

WCHAR lpszDest [260]
 
UINT cchMax =260
 

Macro Definition Documentation

◆ DO_TEST

#define DO_TEST (   exp,
  str 
)
Value:
do { \
StrFormatByteSizeW(exp, lpszDest, cchMax);\
if (lpszDest[1] == L',') lpszDest[1] = L'.';\
ok(_wcsicmp(lpszDest, (str)) == 0, "Expected %s got %s\n",\
} while (0)
UINT cchMax
WCHAR lpszDest[260]
#define wine_dbgstr_w
Definition: kernel32.h:34
DWORD exp
Definition: msg.c:16058
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Definition at line 25 of file StrFormatByteSizeW.c.

Function Documentation

◆ is_lang_english()

static BOOL is_lang_english ( void  )
static

Definition at line 40 of file StrFormatByteSizeW.c.

41{
42 static HMODULE hkernel32 = NULL;
43 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
44 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
45
46 if (!hkernel32)
47 {
48 hkernel32 = GetModuleHandleA("kernel32.dll");
49 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
50 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
51 }
52
53 if (pGetThreadUILanguage)
54 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
55 if (pGetUserDefaultUILanguage)
56 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
57
59}
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
LANGID WINAPI GetUserDefaultLangID(void)
Definition: lang.c:744
USHORT LANGID
Definition: mui.h:9
static HINSTANCE hkernel32
Definition: process.c:66
#define LANG_ENGLISH
Definition: nls.h:52
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define WINAPI
Definition: msvc.h:6

Referenced by START_TEST().

◆ is_locale_english()

static BOOL is_locale_english ( void  )
static

Definition at line 65 of file StrFormatByteSizeW.c.

66{
67 /* Surprisingly GetThreadLocale() is irrelevant here */
69 /* With the checks in DO_TEST, DUTCH can be used here as well.
70 TODO: Add other combinations that should work. */
71 return langid == LANG_ENGLISH || langid == LANG_DUTCH;
72}
LANGID langid
Definition: msctf.idl:644
#define LANG_DUTCH
Definition: nls.h:51

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( StrFormatByteSizeW  )

Definition at line 74 of file StrFormatByteSizeW.c.

75{
76 /* language-dependent test */
78 {
79 skip("An English UI and locale is required for the StrFormat*Size tests\n");
80 return;
81 }
82 DO_TEST(0, L"0 bytes"); // 0x0
83 DO_TEST(1, L"1 bytes"); // 0x1
84 DO_TEST(1024, L"1.00 KB"); // 0x400
85 DO_TEST(1048576, L"1.00 MB"); // 0x100000
86 DO_TEST(1073741824, L"1.00 GB"); // 0x40000000
87 DO_TEST(0x70000000, L"1.75 GB"); // 0x70000000
88 DO_TEST(0x80000000, L"2.00 GB"); // 0x80000000
89 DO_TEST(0x100000000, L"4.00 GB"); // 0x100000000
90 DO_TEST(1099511627776, L"1.00 TB"); // 0x10000000000
91 DO_TEST(1125899906842624, L"1.00 PB"); // 0x4000000000000
92 DO_TEST(1152921504606846976, L"1.00 EB"); // 0x1000000000000000
93 DO_TEST(2305843009213693952, L"2.00 EB"); // 0x2000000000000000
94 DO_TEST(4611686018427387904, L"4.00 EB"); // 0x4000000000000000
95 DO_TEST(0x7fffffffffffffff, L"7.99 EB"); // 0x7fffffffffffffff
96 DO_TEST(0x8000000000000000, L"0 bytes"); // 0x8000000000000000 High Bit Set Here
97 DO_TEST(0xffffffff00000000, L"0 bytes"); // 0xffffffff00000000
98 DO_TEST(0xffffffff00000001, L"1 bytes"); // 0xffffffff00000001
99 DO_TEST(0xffffffff70000000, L"1879048192 bytes"); // 0xffffffff70000000
100 DO_TEST(0xffffffff7fffffff, L"2147483647 bytes"); // 0xffffffff7fffffff
101 DO_TEST(0xffffffff80000000, L"-2147483648 bytes"); // 0xffffffff80000000 // Maximum Negative Number -2.00 GB
102 DO_TEST(0xffffffff80000001, L"-2147483647 bytes"); // 0xffffffff80000001
103 DO_TEST(0xffffffff90000000, L"-1879048192 bytes"); // 0xffffffff90000000
104 DO_TEST(-1073741824, L"-1073741824 bytes"); // 0xffffffffc0000000 -1.00 GB
105 DO_TEST(-1048576, L"-1048576 bytes"); // 0xfffffffffff00000 -1.00 MB
106 DO_TEST(-1024, L"-1024 bytes"); // 0xfffffffffffffc00 -1.00 KB
107 DO_TEST(0xffffffffffffffff, L"-1 bytes"); // 0xffffffffffffffff
108
109 // Here are some large negative tests and they all return zero bytes
110
111 DO_TEST(-4294967296, L"0 bytes"); // 0xffffffff00000000
112 DO_TEST(-8589934592, L"0 bytes"); // 0xfffffffe00000000
113 DO_TEST(-17179869184, L"0 bytes"); // 0xfffffffc00000000
114 DO_TEST(-34359738368, L"0 bytes"); // 0xfffffff800000000
115 DO_TEST(-68719476736, L"0 bytes"); // 0xfffffff000000000
116 DO_TEST(-137438953472, L"0 bytes"); // 0xffffffe000000000
117 DO_TEST(-274877906944, L"0 bytes"); // 0xffffffc000000000
118 DO_TEST(-549755813888, L"0 bytes"); // 0xffffff8000000000
119 DO_TEST(-1099511627776, L"0 bytes"); // 0xffffff0000000000
120 DO_TEST(-1152921504606846976, L"0 bytes"); // 0xf000000000000000
121
122 // These statements create compile errors and seem to be compiler conversion related
123 //DO_TEST(2147483648, L"2.00 GB"); // 2.00 GB & This gives a compile error
124 //DO_TEST(-2147483648, L"0 bytes"); // -2.00 GB & This gives a compile error
125}
#define DO_TEST(exp, str)
static BOOL is_locale_english(void)
static BOOL is_lang_english(void)
#define skip(...)
Definition: atltest.h:64

Variable Documentation

◆ cchMax

_In_ int _In_ int cchMax =260

Definition at line 34 of file StrFormatByteSizeW.c.

Referenced by _Success_(), ConGetTextWidthA(), DdeQueryStringA(), DdeQueryStringW(), DECLARE_INTERFACE_(), DisplayClassInstaller(), CAddressEditBox::GetComboBoxText(), CVfdShExt::GetCommandString(), BtrfsContextMenu::GetCommandString(), CZipFolder::GetCommandString(), CQuickLaunchBand::GetCommandString(), CTrayWindow::GetCommandString(), CBandSiteMenu::GetCommandString(), CShellLink::GetCommandString(), CSendToMenu::GetCommandString(), CCopyMoveToMenu::GetCommandString(), CNewMenu::GetCommandString(), COpenWithMenu::GetCommandString(), getDefaultIconLocation(), GetDisplayName(), CNetConUiObject::GetIconLocation(), CNtObjectFolderExtractIcon::GetIconLocation(), CRegistryFolderExtractIcon::GetIconLocation(), CExtractIcon::GetIconLocation(), CShellLink::GetIconLocation(), getIconLocationForDrive(), getIconLocationForFolder(), BtrfsIconOverlay::GetOverlayInfo(), GetTextFaceA(), ICommDlgBrowser3_fnGetDefaultMenuText(), ATL::CA2AEX< t_nBufferLength >::Init(), ATL::CA2WEX< t_nBufferLength >::Init(), ATL::CW2WEX< t_nBufferLength >::Init(), ATL::CW2AEX< t_nBufferLength >::Init(), MakeShellURLFromPathA(), MD_OnAskCBFormatName(), PathCompactPathExA(), PathCompactPathExW(), ATL::CPathT< StringType >::PathCompactPathExX(), RtlpStringVPrintfWorkerW(), RtlStringCbLengthA(), RtlStringCbLengthW(), RtlStringCchLengthA(), RtlStringCchLengthW(), RtlStringLengthWorkerA(), RtlStringLengthWorkerW(), RtlStringVPrintfExWorkerA(), RtlStringVPrintfWorkerA(), SHELL_PidlGetIconLocationW(), SHStringFromGUIDA(), SHStringFromGUIDW(), StrCatBuffA(), StrCatBuffW(), StrCatChainW(), StrChrNW(), StrFindNIA(), StrFindNIW(), StrFormatByteSize64A(), StrFormatByteSizeA(), StrFormatByteSizeW(), StrFormatKBSizeA(), StrFormatKBSizeW(), StrFromTimeIntervalA(), StrFromTimeIntervalW(), StringCbLengthA(), StringCbLengthW(), StringCchLengthA(), StringCchLengthW(), StringLengthWorkerA(), StringLengthWorkerW(), StringVPrintfExWorkerA(), StringVPrintfExWorkerW(), StringVPrintfWorkerA(), StringVPrintfWorkerW(), StrNCatA(), StrNCatW(), StrStrN(), StrStrNIW(), StrStrNW(), test_ordinal_imports(), and WDML_QueryString().

◆ lpszDest