ReactOS  0.4.14-dev-614-gbfd8a84
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 ALLOC_EXPECT(a, b)   a
 
#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 158 of file CString.cpp.

◆ _X [2/2]

#define _X (   x)    x

Definition at line 158 of file CString.cpp.

◆ ALLOC_EXPECT

#define ALLOC_EXPECT (   a,
  b 
)    a

Definition at line 125 of file CString.cpp.

◆ CStringX [1/2]

#define CStringX   CStringW

Definition at line 157 of file CString.cpp.

◆ CStringX [2/2]

#define CStringX   CStringA

Definition at line 157 of file CString.cpp.

◆ dbgstrx [1/2]

#define dbgstrx (   x)    wine_dbgstr_w(x)

Definition at line 161 of file CString.cpp.

◆ dbgstrx [2/2]

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

Definition at line 161 of file CString.cpp.

◆ GetWindowsDirectoryX [1/2]

#define GetWindowsDirectoryX   GetWindowsDirectoryW

Definition at line 163 of file CString.cpp.

◆ GetWindowsDirectoryX [2/2]

#define GetWindowsDirectoryX   GetWindowsDirectoryA

Definition at line 163 of file CString.cpp.

◆ MAKEINTRESOURCEX [1/2]

#define MAKEINTRESOURCEX (   x)    MAKEINTRESOURCEW(x)

Definition at line 164 of file CString.cpp.

◆ MAKEINTRESOURCEX [2/2]

#define MAKEINTRESOURCEX (   x)    MAKEINTRESOURCEA(x)

Definition at line 164 of file CString.cpp.

◆ MAKEINTRESOURCEY [1/2]

#define MAKEINTRESOURCEY (   x)    MAKEINTRESOURCEA(x)

Definition at line 165 of file CString.cpp.

◆ MAKEINTRESOURCEY [2/2]

#define MAKEINTRESOURCEY (   x)    MAKEINTRESOURCEW(x)

Definition at line 165 of file CString.cpp.

◆ ok [1/2]

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

Definition at line 162 of file CString.cpp.

◆ ok [2/2]

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

Definition at line 162 of file CString.cpp.

◆ TEST_NAMEX [1/2]

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

Definition at line 156 of file CString.cpp.

◆ TEST_NAMEX [2/2]

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

Definition at line 156 of file CString.cpp.

◆ XCHAR [1/2]

#define XCHAR   WCHAR

Definition at line 159 of file CString.cpp.

◆ XCHAR [2/2]

#define XCHAR   CHAR

Definition at line 159 of file CString.cpp.

◆ YCHAR [1/2]

#define YCHAR   CHAR

Definition at line 160 of file CString.cpp.

◆ YCHAR [2/2]

#define YCHAR   WCHAR

Definition at line 160 of file CString.cpp.

Function Documentation

◆ START_TEST()

START_TEST ( CString  )

Definition at line 169 of file CString.cpp.

170 {
171  test_basetypes();
172 
173  if ((ALLOC_EXPECT(1, 2)) == 2)
174  {
175  skip("Ignoring real GetAllocLength() lenght\n");
176  }
177 
178  test_operators_initW();
179  test_operators_initA();
180 
181  test_compareW();
182  test_compareA();
183 
184  test_findW();
185  test_findA();
186 
187  test_formatW();
188  test_formatA();
189 
190  test_substrW();
191  test_substrA();
192 
193  test_replaceW();
194  test_replaceA();
195 
196  test_trimW();
197  test_trimA();
198 
199  test_envW();
200  test_envA();
201 
202  test_load_strW();
203  test_load_strA();
204 
205  test_bstrW();
206  test_bstrA();
207 }
static void test_basetypes()
Definition: CString.cpp:41
#define ALLOC_EXPECT(a, b)
Definition: CString.cpp:125
#define skip(...)
Definition: atltest.h:64

◆ 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 }
char strA[12]
Definition: clipboard.c:2028
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define _countof(array)
Definition: fontsub.cpp:30
#define str_len
Definition: treelist.c:89
GLdouble n
Definition: glext.h:7729
traits_test g_Tests[]
Definition: CString.cpp:26
WCHAR strW[12]
Definition: clipboard.c:2029
#define ok
Definition: CString.cpp:162
static const WCHAR L[]
Definition: oid.c:1250
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define memset(x, y, z)
Definition: compat.h:39

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 },
}
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 26 of file CString.cpp.

Referenced by test_basetypes().