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 10 LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo) 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"); 17 return EXCEPTION_CONTINUE_SEARCH; 18 } 19 20 LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo) 21 { 22 /* Vectored Exception Handler that should be called for lstrlen(<invalid_ptr>) */ 23 ok(TRUE, "VEHandler_2 not called?\n"); 24 return EXCEPTION_CONTINUE_SEARCH; 25 } 26 27 START_TEST(lstrlen) 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)0xbaadf00d) == 0, "lstrlenA should have returned 0.\n"); 51 ok(lstrlenW((LPWSTR)0xbaadf00d) == 0, "lstrlenW should have returned 0.\n"); 52 RemoveVectoredExceptionHandler(pVEH); 53 } 54