ReactOS 0.4.16-dev-853-g88d9285
StrRStr.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for StrRStrA/W
5 * COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "shelltest.h"
9#include <versionhelpers.h>
10
11typedef PSTR (WINAPI *FN_StrRStrA)(PCSTR, PCSTR, PCSTR pszSearch);
12typedef PWSTR (WINAPI *FN_StrRStrW)(PCWSTR, PCWSTR, PCWSTR pszSearch);
13
15{
16 PCSTR psz, pch;
17 PSTR ret;
19
20 if (!StrRStrA)
21 {
22 skip("StrRStrA not found\n");
23 return;
24 }
25
26 psz = "ABCBC";
27 ret = StrRStrA(psz, NULL, "BC");
28 ok_ptr(ret, psz + 3);
29
30 psz = "ABCBC";
31 pch = &psz[2];
32 ret = StrRStrA(psz, pch, "BC");
33 ok_ptr(ret, &psz[1]);
34
35 psz = "ABCBC";
36 ret = StrRStrA(psz, psz, "BC");
37 ok(!ret, "ret was '%s'\n", ret);
38
39 psz = "ABCBC";
40 pch = &psz[lstrlenA(psz)];
41 ret = StrRStrA(psz, pch, "BC");
42 ok_ptr(ret, psz + 3);
43}
44
46{
47 PCWSTR psz, pch;
48 PWSTR ret;
50
51 if (!StrRStrW)
52 {
53 skip("StrRStrW not found\n");
54 return;
55 }
56
57 psz = L"ABCBC";
58 ret = StrRStrW(psz, NULL, L"BC");
59 ok_ptr(ret, psz + 3);
60
61 psz = L"ABCBC";
62 pch = &psz[2];
63 ret = StrRStrW(psz, pch, L"BC");
64 ok_ptr(ret, &psz[1]);
65
66 psz = L"ABCBC";
67 ret = StrRStrW(psz, psz, L"BC");
68 ok(!ret, "ret was '%S'\n", ret);
69
70 psz = L"ABCBC";
71 pch = &psz[lstrlenW(psz)];
72 ret = StrRStrW(psz, pch, L"BC");
73 ok_ptr(ret, psz + 3);
74}
75
77{
78 return IsWindowsVersionOrGreater(5, 2, 2);
79}
80
81START_TEST(StrRStr)
82{
84 {
85 skip("Vista+\n");
86 return;
87 }
88
90 {
91 skip("Before 2K3 SP3\n");
92 return;
93 }
94
97}
BOOL IsWindowsServer2003SP2OrGreater(void)
PWSTR(WINAPI * FN_StrRStrW)(PCWSTR, PCWSTR, PCWSTR pszSearch)
Definition: StrRStr.cpp:12
PSTR(WINAPI * FN_StrRStrA)(PCSTR, PCSTR, PCSTR pszSearch)
Definition: StrRStr.cpp:11
static VOID TEST_StrRStrA(VOID)
Definition: StrRStr.cpp:14
static VOID TEST_StrRStrW(VOID)
Definition: StrRStr.cpp:45
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define lstrlenW
Definition: compat.h:750
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
EXTERN_C PSTR WINAPI StrRStrA(_In_ PCSTR pszSrc, _In_opt_ PCSTR pszLast, _In_ PCSTR pszSearch)
Definition: utils.cpp:40
EXTERN_C PWSTR WINAPI StrRStrW(_In_ PCWSTR pszSrc, _In_opt_ PCWSTR pszLast, _In_ PCWSTR pszSearch)
Definition: utils.cpp:72
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define pch(ap)
Definition: match.c:418
#define L(x)
Definition: ntvdm.h:50
uint16_t * PWSTR
Definition: typedefs.h:56
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
const char * PCSTR
Definition: typedefs.h:52
VERSIONHELPERAPI IsWindowsVistaOrGreater()
VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
int ret
#define WINAPI
Definition: msvc.h:6
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581