ReactOS  0.4.15-dev-1207-g698a8e6
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  */
40 pVEH = 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");
43 RemoveVectoredExceptionHandler(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  */
49 pVEH = 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");
52 RemoveVectoredExceptionHandler(pVEH);
53 }
#define TRUE
Definition: types.h:120
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:609
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define WINAPI
Definition: msvc.h:6
LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
Definition: lstrlen.c:20
static const WCHAR L[]
Definition: oid.c:1250
#define lstrlen
Definition: winbase.h:3716
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ok(value,...)
Definition: atltest.h:57
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
Definition: lstrlen.c:10
WCHAR * LPWSTR
Definition: xmlstorage.h:184
START_TEST(lstrlen)
Definition: lstrlen.c:27