ReactOS 0.4.15-dev-8227-g32d615f
lstrlen.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Tests for lstrlenA/W
5 * PROGRAMMER: Hermes Belusca-Maito
6 */
7
8#include "precomp.h"
9
11{
12 /*
13 * Vectored Exception Handler possibly called for lstrlen(NULL).
14 * Expected not to be called!
15 */
16 ok(FALSE, "VEHandler_1 called!\n");
18}
19
21{
22 /* Vectored Exception Handler that should be called for lstrlen(<invalid_ptr>) */
23 ok(TRUE, "VEHandler_2 not called?\n");
25}
26
28{
29 PVOID pVEH;
30
31 /* Test basic functionality */
32 ok(lstrlenA( "Hello World!") == 12, "lstrlenA failed!\n");
33 ok(lstrlenW(L"Hello World!") == 12, "lstrlenW failed!\n");
34
35 /*
36 * NULL buffer is special and is considered separately;
37 * no internal exception is generated.
38 * Use Vectored Exception Handling to monitor for first-chance exceptions.
39 */
40pVEH = AddVectoredExceptionHandler(1, VEHandler_1);
41 ok(lstrlenA(NULL) == 0, "lstrlenA should have returned 0.\n");
42 ok(lstrlenW(NULL) == 0, "lstrlenW should have returned 0.\n");
43RemoveVectoredExceptionHandler(pVEH);
44
45 /*
46 * Test some invalid buffers. Internal exceptions should be generated.
47 * Use Vectored Exception Handling to monitor for first-chance exceptions.
48 */
49pVEH = AddVectoredExceptionHandler(1, VEHandler_2);
50 ok(lstrlenA( (LPSTR)(LONG_PTR)0xbaadf00d) == 0, "lstrlenA should have returned 0.\n");
51 ok(lstrlenW((LPWSTR)(LONG_PTR)0xbaadf00d) == 0, "lstrlenW should have returned 0.\n");
52RemoveVectoredExceptionHandler(pVEH);
53}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define lstrlenW
Definition: compat.h:750
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
Definition: lstrlen.c:20
LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
Definition: lstrlen.c:10
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define lstrlen
Definition: winbase.h:3876
#define WINAPI
Definition: msvc.h:6
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184