ReactOS 0.4.15-dev-7961-gdcf9eb0
CString.cpp File Reference
#include <atlstr.h>
#include "resource.h"
#include "atltest.h"
#include "CString.inl"
Include dependency graph for CString.cpp:

Go to the source code of this file.

Classes

struct  traits_test
 

Macros

#define TEST_NAMEX(name)   void test_##name##W()
 
#define CStringX   CStringW
 
#define _X(x)   L ## x
 
#define XCHAR   WCHAR
 
#define YCHAR   CHAR
 
#define dbgstrx(x)   wine_dbgstr_w(x)
 
#define ok   ok_("CStringW:\n" __FILE__, __LINE__)
 
#define GetWindowsDirectoryX   GetWindowsDirectoryW
 
#define MAKEINTRESOURCEX(x)   MAKEINTRESOURCEW(x)
 
#define MAKEINTRESOURCEY(x)   MAKEINTRESOURCEA(x)
 
#define TEST_NAMEX(name)   void test_##name##A()
 
#define CStringX   CStringA
 
#define _X(x)   x
 
#define XCHAR   CHAR
 
#define YCHAR   WCHAR
 
#define dbgstrx(x)   (const char*)x
 
#define ok   ok_("CStringA:\n" __FILE__, __LINE__)
 
#define GetWindowsDirectoryX   GetWindowsDirectoryA
 
#define MAKEINTRESOURCEX(x)   MAKEINTRESOURCEA(x)
 
#define MAKEINTRESOURCEY(x)   MAKEINTRESOURCEW(x)
 

Functions

static void test_basetypes ()
 
 START_TEST (CString)
 

Variables

traits_test g_Tests []
 

Macro Definition Documentation

◆ _X [1/2]

#define _X (   x)    L ## x

Definition at line 149 of file CString.cpp.

◆ _X [2/2]

#define _X (   x)    x

Definition at line 149 of file CString.cpp.

◆ CStringX [1/2]

#define CStringX   CStringW

Definition at line 148 of file CString.cpp.

◆ CStringX [2/2]

#define CStringX   CStringA

Definition at line 148 of file CString.cpp.

◆ dbgstrx [1/2]

#define dbgstrx (   x)    wine_dbgstr_w(x)

Definition at line 152 of file CString.cpp.

◆ dbgstrx [2/2]

#define dbgstrx (   x)    (const char*)x

Definition at line 152 of file CString.cpp.

◆ GetWindowsDirectoryX [1/2]

#define GetWindowsDirectoryX   GetWindowsDirectoryW

Definition at line 154 of file CString.cpp.

◆ GetWindowsDirectoryX [2/2]

#define GetWindowsDirectoryX   GetWindowsDirectoryA

Definition at line 154 of file CString.cpp.

◆ MAKEINTRESOURCEX [1/2]

#define MAKEINTRESOURCEX (   x)    MAKEINTRESOURCEW(x)

Definition at line 155 of file CString.cpp.

◆ MAKEINTRESOURCEX [2/2]

#define MAKEINTRESOURCEX (   x)    MAKEINTRESOURCEA(x)

Definition at line 155 of file CString.cpp.

◆ MAKEINTRESOURCEY [1/2]

#define MAKEINTRESOURCEY (   x)    MAKEINTRESOURCEA(x)

Definition at line 156 of file CString.cpp.

◆ MAKEINTRESOURCEY [2/2]

#define MAKEINTRESOURCEY (   x)    MAKEINTRESOURCEW(x)

Definition at line 156 of file CString.cpp.

◆ ok [1/2]

#define ok   ok_("CStringW:\n" __FILE__, __LINE__)

Definition at line 153 of file CString.cpp.

◆ ok [2/2]

#define ok   ok_("CStringA:\n" __FILE__, __LINE__)

Definition at line 153 of file CString.cpp.

◆ TEST_NAMEX [1/2]

#define TEST_NAMEX (   name)    void test_##name##W()

Definition at line 147 of file CString.cpp.

◆ TEST_NAMEX [2/2]

#define TEST_NAMEX (   name)    void test_##name##A()

Definition at line 147 of file CString.cpp.

◆ XCHAR [1/2]

#define XCHAR   WCHAR

Definition at line 150 of file CString.cpp.

◆ XCHAR [2/2]

#define XCHAR   CHAR

Definition at line 150 of file CString.cpp.

◆ YCHAR [1/2]

#define YCHAR   CHAR

Definition at line 151 of file CString.cpp.

◆ YCHAR [2/2]

#define YCHAR   WCHAR

Definition at line 151 of file CString.cpp.

Function Documentation

◆ START_TEST()

START_TEST ( CString  )

Definition at line 160 of file CString.cpp.

161{
163
164 test_operators_initW();
165 test_operators_initA();
166
167 test_compareW();
168 test_compareA();
169
170 test_findW();
171 test_findA();
172
173 test_formatW();
174 test_formatA();
175
176 test_substrW();
177 test_substrA();
178
179 test_replaceW();
180 test_replaceA();
181
182 test_trimW();
183 test_trimA();
184
185 test_envW();
186 test_envA();
187
188 test_load_strW();
189 test_load_strA();
190
191 test_bstrW();
192 test_bstrA();
193
194 test_tokenizeW();
195 test_tokenizeA();
196}
static void test_basetypes()
Definition: CString.cpp:41

◆ test_basetypes()

static void test_basetypes ( )
static

Definition at line 41 of file CString.cpp.

42{
43 int len;
44 char bufA[10];
45 wchar_t bufW[10];
46
47 for (size_t n = 0; n < _countof(g_Tests); ++n)
48 {
50 ok(len == g_Tests[n].exp_1, "Expected len to be %i, was %i for %u (A)\n", g_Tests[n].exp_1, len, n);
51
53 ok(len == g_Tests[n].exp_2, "Expected len to be %i, was %i for %u (A,len)\n", g_Tests[n].exp_2, len, n);
54
56 ok(len == g_Tests[n].exp_3, "Expected len to be %i, was %i for %u (W)\n", g_Tests[n].exp_3, len, n);
57
59 ok(len == g_Tests[n].exp_4, "Expected len to be %i, was %i for %u (W,len)\n", g_Tests[n].exp_4, len, n);
60
61 if (g_Tests[n].strA && g_Tests[n].strW)
62 {
63 memset(bufA, 'x', sizeof(bufA));
65 char ch = bufA[g_Tests[n].exp_1];
66 ok(ch == '\0', "Expected %i to be \\0, was: %c (%i) for %u\n", g_Tests[n].exp_1, ch, (int)ch, n);
67 ok(!strcmp(bufA, g_Tests[n].strA), "Expected bufA to be %s, was: %s for %u\n", g_Tests[n].strA, bufA, n);
68 ch = bufA[g_Tests[n].exp_1+1];
69 ok(ch == 'x', "Expected %i to be 'x', was: %c (%i) for %u\n", g_Tests[n].exp_1+1, ch, (int)ch, n);
70 }
71
72 if (g_Tests[n].strA && g_Tests[n].strW)
73 {
74 memset(bufA, 'x', sizeof(bufA));
76 char ch = bufA[g_Tests[n].exp_1];
77 ok(ch == '\0', "Expected %i to be \\0, was: %c (%i) for %u\n", g_Tests[n].exp_1, ch, (int)ch, n);
78 ok(!strcmp(bufA, g_Tests[n].strA), "Expected bufA to be %s, was: %s for %u\n", g_Tests[n].strA, bufA, n);
79 ch = bufA[g_Tests[n].exp_1+1];
80 ok(ch == 'x', "Expected %i to be 'x', was: %c (%i) for %u\n", g_Tests[n].exp_1+1, ch, (int)ch, n);
81 }
82
83 // wchar_t --> please note, swapped the expectations from 2 and 4 !
85 ok(len == g_Tests[n].exp_1, "Expected len to be %i, was %i for %u (A)\n", g_Tests[n].exp_1, len, n);
86
88 ok(len == g_Tests[n].exp_4, "Expected len to be %i, was %i for %u (A,len)\n", g_Tests[n].exp_4, len, n);
89
91 ok(len == g_Tests[n].exp_3, "Expected len to be %i, was %i for %u (W)\n", g_Tests[n].exp_3, len, n);
92
94 ok(len == g_Tests[n].exp_2, "Expected len to be %i, was %i for %u (W,len)\n", g_Tests[n].exp_2, len, n);
95
96 if (g_Tests[n].strA && g_Tests[n].strW)
97 {
98 memset(bufW, 'x', sizeof(bufW));
100 wchar_t ch = bufW[g_Tests[n].exp_1];
101 ok(ch == L'\0', "Expected %i to be \\0, was: %c (%i) for %u\n", g_Tests[n].exp_1, ch, (int)ch, n);
102 ok(!wcscmp(bufW, g_Tests[n].strW), "Expected bufW to be %s, was: %s for %u\n", wine_dbgstr_w(g_Tests[n].strW), wine_dbgstr_w(bufW), n);
103 ch = bufW[g_Tests[n].exp_1+1];
104 ok(ch == 30840, "Expected %i to be %i for %u\n", g_Tests[n].exp_1+1, (int)ch, n);
105 }
106
107 if (g_Tests[n].strA && g_Tests[n].strW)
108 {
109 memset(bufW, 'x', sizeof(bufW));
111 wchar_t ch = bufW[g_Tests[n].exp_1];
112 ok(ch == '\0', "Expected %i to be \\0, was: %c (%i) for %u\n", g_Tests[n].exp_1, ch, (int)ch, n);
113 ok(!wcscmp(bufW, g_Tests[n].strW), "Expected bufW to be %s, was: %s for %u\n", wine_dbgstr_w(g_Tests[n].strW), wine_dbgstr_w(bufW), n);
114 ch = bufW[g_Tests[n].exp_1+1];
115 ok(ch == 30840, "Expected %i to be %i for %u\n", g_Tests[n].exp_1+1, (int)ch, n);
116 }
117 }
118}
traits_test g_Tests[]
Definition: CString.cpp:26
#define ok
Definition: CString.cpp:153
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static int __cdecl GetBaseTypeLength(_In_z_ LPCWSTR pszSource) noexcept
Definition: cstringt.h:29
static void __cdecl ConvertToBaseType(_Out_writes_(nDestLength) LPWSTR pszDest, _In_ int nDestLength, _In_ LPCWSTR pszSrc, _In_ int nSrcLength=-1)
Definition: cstringt.h:55
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
#define wine_dbgstr_w
Definition: kernel32.h:34
WCHAR strW[12]
Definition: clipboard.c:2029
char strA[12]
Definition: clipboard.c:2028
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define memset(x, y, z)
Definition: compat.h:39
#define _countof(array)
Definition: sndvol32.h:68
#define str_len
Definition: treelist.c:89

Referenced by START_TEST().

Variable Documentation

◆ g_Tests

traits_test g_Tests[]
Initial value:
= {
{ NULL, NULL, 0, 0, 0, -1, 0 },
{ NULL, NULL, -1, 0, -1, -1, 0 },
{ NULL, NULL, 1, 0, 1, -1, 0 },
{ "", L"", 0, 0, 0, 0, 0 },
{ "", L"", -1, 0, -1, 0, 1 },
{ "", L"", 1, 0, 1, 0, 1 },
{ "AAABBB", L"AAABBB", 0, 6, 0, 6, 0 },
{ "AAABBB", L"AAABBB", 3, 6, 3, 6, 3 },
{ "AAABBB", L"AAABBB", -1, 6, -1, 6, 7 },
}
#define NULL
Definition: types.h:112

Definition at line 26 of file CString.cpp.

Referenced by test_basetypes().