ReactOS 0.4.15-dev-7961-gdcf9eb0
Int64ToString.cpp File Reference
#include "shelltest.h"
#include <undocshell.h>
#include <versionhelpers.h>
Include dependency graph for Int64ToString.cpp:

Go to the source code of this file.

Classes

struct  tagTEST_RETURN
 
struct  tagTEST_ENTRY
 

Macros

#define DATA0   2, FALSE, 3, L".", L",", 0
 
#define DATA1   3, TRUE, 3, L"<>", L":", 1
 

Typedefs

typedef struct tagTEST_RETURN TEST_RETURN
 
typedef struct tagTEST_RETURNPTEST_RETURN
 
typedef struct tagTEST_ENTRY TEST_ENTRY
 
typedef struct tagTEST_ENTRYPTEST_ENTRY
 

Functions

static void DoTestEntry (BOOL bVista, const TEST_ENTRY *pEntry)
 
static void Test_EntryTest (BOOL bVista)
 
static void Test_Int64ToString (BOOL bVista)
 
static void Test_LargeIntegerToString (BOOL bVista)
 
 START_TEST (Int64ToString)
 

Variables

static const TEST_ENTRY s_Entries []
 
static const SIZE_T s_cEntries = _countof(s_Entries)
 

Macro Definition Documentation

◆ DATA0

#define DATA0   2, FALSE, 3, L".", L",", 0

Definition at line 34 of file Int64ToString.cpp.

◆ DATA1

#define DATA1   3, TRUE, 3, L"<>", L":", 1

Definition at line 35 of file Int64ToString.cpp.

Typedef Documentation

◆ PTEST_ENTRY

◆ PTEST_RETURN

◆ TEST_ENTRY

◆ TEST_RETURN

Function Documentation

◆ DoTestEntry()

static void DoTestEntry ( BOOL  bVista,
const TEST_ENTRY pEntry 
)
static

Definition at line 54 of file Int64ToString.cpp.

55{
56 INT lineno = pEntry->lineno;
57
58 WCHAR szDecimalSep[10], szThousandSep[10];
59 lstrcpynW(szDecimalSep, pEntry->pszDecimalSep, _countof(szDecimalSep));
60 lstrcpynW(szThousandSep, pEntry->pszThousandSep, _countof(szThousandSep));
61
63 {
64 pEntry->NumDigits, pEntry->LeadingZero, pEntry->Grouping,
65 szDecimalSep, szThousandSep, pEntry->NegativeOrder
66 };
67
68 WCHAR szBuff[64];
69 lstrcpynW(szBuff, L"#####", _countof(szBuff));
70
71 INT ret = Int64ToString(pEntry->value, szBuff, _countof(szBuff), TRUE, &format, -1);
72 if (bVista)
73 {
74 ok(pEntry->Vista.ret == ret, "Line %d: %d vs %d\n", lineno, pEntry->Vista.ret, ret);
75 ok(lstrcmpW(pEntry->Vista.text, szBuff) == 0, "Line %d: %ls vs %ls\n",
76 lineno, pEntry->Vista.text, szBuff);
77 }
78 else
79 {
80 ok(pEntry->NonVista.ret == ret, "Line %d: %d vs %d\n", lineno, pEntry->NonVista.ret, ret);
81 ok(lstrcmpW(pEntry->NonVista.text, szBuff) == 0, "Line %d: %ls vs %ls\n",
82 lineno, pEntry->NonVista.text, szBuff);
83 }
84
85 lstrcpynW(szBuff, L"#####", _countof(szBuff));
86
87 LARGE_INTEGER LInt;
88 LInt.QuadPart = pEntry->value;
89 ret = LargeIntegerToString(&LInt, szBuff, _countof(szBuff), TRUE, &format, -1);
90 if (bVista)
91 {
92 ok(pEntry->Vista.ret == ret, "Line %d: %d vs %d\n", lineno, pEntry->Vista.ret, ret);
93 ok(lstrcmpW(pEntry->Vista.text, szBuff) == 0, "Line %d: %ls vs %ls\n",
94 lineno, pEntry->Vista.text, szBuff);
95 }
96 else
97 {
98 ok(pEntry->NonVista.ret == ret, "Line %d: %d vs %d\n", lineno, pEntry->NonVista.ret, ret);
99 ok(lstrcmpW(pEntry->NonVista.text, szBuff) == 0, "Line %d: %ls vs %ls\n",
100 lineno, pEntry->NonVista.text, szBuff);
101 }
102}
#define ok(value,...)
Definition: atltest.h:57
#define TRUE
Definition: types.h:120
#define lstrcpynW
Definition: compat.h:738
EXTERN_C INT WINAPI Int64ToString(_In_ LONGLONG llValue, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
Definition: utils.cpp:871
EXTERN_C INT WINAPI LargeIntegerToString(_In_ const LARGE_INTEGER *pLargeInt, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
Definition: utils.cpp:909
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:68
int32_t INT
Definition: typedefs.h:58
LONGLONG QuadPart
Definition: typedefs.h:114
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Test_EntryTest().

◆ START_TEST()

START_TEST ( Int64ToString  )

Definition at line 186 of file Int64ToString.cpp.

187{
188 BOOL bVista = IsWindowsVistaOrGreater();
189 trace("bVista: %d\n", bVista);
190
191 Test_EntryTest(bVista);
192 Test_Int64ToString(bVista);
194}
static void Test_EntryTest(BOOL bVista)
static void Test_Int64ToString(BOOL bVista)
static void Test_LargeIntegerToString(BOOL bVista)
#define trace
Definition: atltest.h:70
unsigned int BOOL
Definition: ntddk_ex.h:94
VERSIONHELPERAPI IsWindowsVistaOrGreater()

◆ Test_EntryTest()

static void Test_EntryTest ( BOOL  bVista)
static

Definition at line 104 of file Int64ToString.cpp.

105{
106 for (SIZE_T i = 0; i < s_cEntries; ++i)
107 {
108 DoTestEntry(bVista, &s_Entries[i]);
109 }
110}
static const TEST_ENTRY s_Entries[]
static const SIZE_T s_cEntries
static void DoTestEntry(BOOL bVista, const TEST_ENTRY *pEntry)
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
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by START_TEST().

◆ Test_Int64ToString()

static void Test_Int64ToString ( BOOL  bVista)
static

Definition at line 112 of file Int64ToString.cpp.

113{
114 WCHAR szBuff[64];
115 INT ret;
116
117 ret = Int64ToString(0, szBuff, _countof(szBuff), FALSE, NULL, 0);
118 ok_int(ret, 1);
119 ok_wstr(szBuff, L"0");
120
121 ret = Int64ToString(1, szBuff, _countof(szBuff), FALSE, NULL, 0);
122 ok_int(ret, 1);
123 ok_wstr(szBuff, L"1");
124
125 ret = Int64ToString(-9999, szBuff, _countof(szBuff), FALSE, NULL, 0);
126 if (bVista)
127 {
128 ok_int(ret, 5);
129 ok_wstr(szBuff, L"-9999");
130 }
131 else
132 {
133 ok_int(ret, 4);
134 ok_wstr(szBuff, L"''''");
135 }
136
137 ret = Int64ToString(10000, szBuff, _countof(szBuff), FALSE, NULL, 0);
138 ok_int(ret, 5);
139 ok_wstr(szBuff, L"10000");
140
141 ret = Int64ToString(0xE8D4A51000LL, szBuff, _countof(szBuff), FALSE, NULL, 0);
142 ok_int(ret, 13);
143 ok_wstr(szBuff, L"1000000000000");
144}
#define ok_wstr(x, y)
Definition: atltest.h:130
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117

Referenced by START_TEST().

◆ Test_LargeIntegerToString()

static void Test_LargeIntegerToString ( BOOL  bVista)
static

Definition at line 146 of file Int64ToString.cpp.

147{
148 LARGE_INTEGER LInt;
149 WCHAR szBuff[64];
150 INT ret;
151
152 LInt.QuadPart = 0;
153 ret = LargeIntegerToString(&LInt, szBuff, _countof(szBuff), FALSE, NULL, 0);
154 ok_int(ret, 1);
155 ok_wstr(szBuff, L"0");
156
157 LInt.QuadPart = 1;
158 ret = LargeIntegerToString(&LInt, szBuff, _countof(szBuff), FALSE, NULL, 0);
159 ok_int(ret, 1);
160 ok_wstr(szBuff, L"1");
161
162 LInt.QuadPart = -9999;
163 ret = LargeIntegerToString(&LInt, szBuff, _countof(szBuff), FALSE, NULL, 0);
164 if (bVista)
165 {
166 ok_int(ret, 5);
167 ok_wstr(szBuff, L"-9999");
168 }
169 else
170 {
171 ok_int(ret, 4);
172 ok_wstr(szBuff, L"''''");
173 }
174
175 LInt.QuadPart = 10000;
176 ret = LargeIntegerToString(&LInt, szBuff, _countof(szBuff), FALSE, NULL, 0);
177 ok_int(ret, 5);
178 ok_wstr(szBuff, L"10000");
179
180 LInt.QuadPart = 0xE8D4A51000LL;
181 ret = LargeIntegerToString(&LInt, szBuff, _countof(szBuff), FALSE, NULL, 0);
182 ok_int(ret, 13);
183 ok_wstr(szBuff, L"1000000000000");
184}

Referenced by START_TEST().

Variable Documentation

◆ s_cEntries

const SIZE_T s_cEntries = _countof(s_Entries)
static

Definition at line 52 of file Int64ToString.cpp.

Referenced by Test_EntryTest().

◆ s_Entries

const TEST_ENTRY s_Entries[]
static
Initial value:
=
{
{ __LINE__, 0, DATA0, { 3, L".00" }, { 3, L".00" } },
{ __LINE__, 0, DATA1, { 6, L"0<>000" }, { 6, L"0<>000" } },
{ __LINE__, 1, DATA0, { 4, L"1.00" }, { 4, L"1.00" } },
{ __LINE__, 1, DATA1, { 6, L"1<>000" }, { 6, L"1<>000" } },
{ __LINE__, -999, DATA0, { 0, L"#####" }, { 8, L"(999.00)" } },
{ __LINE__, -999, DATA1, { 0, L"#####" }, { 9, L"-999<>000" } },
{ __LINE__, 100000, DATA0, { 10, L"100,000.00" }, { 10, L"100,000.00" } },
{ __LINE__, 100000, DATA1, { 12, L"100:000<>000" }, { 12, L"100:000<>000" } },
{ __LINE__, 0xE8D4A51000LL, DATA0, { 20, L"1,000,000,000,000.00" }, { 20, L"1,000,000,000,000.00" } },
{ __LINE__, 0xE8D4A51000LL, DATA1, { 22, L"1:000:000:000:000<>000" }, { 22, L"1:000:000:000:000<>000" } },
{ __LINE__, 0x7FFFFFFFFFFFFFFFLL, DATA0, { 28, L"9,223,372,036,854,775,807.00" }, { 28, L"9,223,372,036,854,775,807.00" } },
{ __LINE__, 0x7FFFFFFFFFFFFFFFLL, DATA1, { 30, L"9:223:372:036:854:775:807<>000" }, { 30, L"9:223:372:036:854:775:807<>000" } },
}
#define DATA1
#define DATA0

Definition at line 37 of file Int64ToString.cpp.

Referenced by Test_EntryTest().