[KERNEL32_APITEST] Add a few tests for GetVolumeInformation that were used to fix...
[reactos.git] / modules / rostests / apitests / kernel32 / lstrlen.c
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 <apitest.h>
9
10 #define WIN32_NO_STATUS
11 #include <stdio.h>
12
13 LONG WINAPI VEHandler_1(PEXCEPTION_POINTERS ExceptionInfo)
14 {
15 /*
16 * Vectored Exception Handler possibly called for lstrlen(NULL).
17 * Expected not to be called!
18 */
19 ok(FALSE, "VEHandler_1 called!\n");
20 return EXCEPTION_CONTINUE_SEARCH;
21 }
22
23 LONG WINAPI VEHandler_2(PEXCEPTION_POINTERS ExceptionInfo)
24 {
25 /* Vectored Exception Handler that should be called for lstrlen(<invalid_ptr>) */
26 ok(TRUE, "VEHandler_2 not called?\n");
27 return EXCEPTION_CONTINUE_SEARCH;
28 }
29
30 START_TEST(lstrlen)
31 {
32 PVOID pVEH;
33
34 /* Test basic functionality */
35 ok(lstrlenA( "Hello World!") == 12, "lstrlenA failed!\n");
36 ok(lstrlenW(L"Hello World!") == 12, "lstrlenW failed!\n");
37
38 /*
39 * NULL buffer is special and is considered separately;
40 * no internal exception is generated.
41 * Use Vectored Exception Handling to monitor for first-chance exceptions.
42 */
43 pVEH = AddVectoredExceptionHandler(1, VEHandler_1);
44 ok(lstrlenA(NULL) == 0, "lstrlenA should have returned 0.\n");
45 ok(lstrlenW(NULL) == 0, "lstrlenW should have returned 0.\n");
46 RemoveVectoredExceptionHandler(pVEH);
47
48 /*
49 * Test some invalid buffers. Internal exceptions should be generated.
50 * Use Vectored Exception Handling to monitor for first-chance exceptions.
51 */
52 pVEH = AddVectoredExceptionHandler(1, VEHandler_2);
53 ok(lstrlenA( (LPSTR)0xbaadf00d) == 0, "lstrlenA should have returned 0.\n");
54 ok(lstrlenW((LPWSTR)0xbaadf00d) == 0, "lstrlenW should have returned 0.\n");
55 RemoveVectoredExceptionHandler(pVEH);
56 }