1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*============================================================
6**
7** Source: test.c
8**
9** Purpose: Test for FreeEnvironmentStringsW() function
10**
11**
12**=========================================================*/
13
14#define UNICODE
15#include <palsuite.h>
16
17int __cdecl main(int argc, char *argv[])
18{
19
20 WCHAR CapturedEnvironment[] = {'T','E','S','T','\0'};
21 BOOL TheResult = 0;
22 LPWSTR lpCapturedEnvironment = NULL;
23
24 /*
25 * Initialize the PAL and return FAILURE if this fails
26 */
27
28 if(0 != (PAL_Initialize(argc, argv)))
29 {
30 return FAIL;
31 }
32
33 lpCapturedEnvironment = (LPWSTR)malloc( sizeof(CapturedEnvironment) /
34 sizeof(CapturedEnvironment[0]) );
35
36 if ( lpCapturedEnvironment )
37 {
38 memcpy( lpCapturedEnvironment, CapturedEnvironment,
39 sizeof(CapturedEnvironment) / sizeof(CapturedEnvironment[0]) );
40 }
41 else
42 {
43 Fail( "malloc() failed to allocate memory.\n" );
44 }
45 /* Even if this is not a valid Environment block, the function will
46 still return success
47 */
48
49 TheResult = FreeEnvironmentStrings( lpCapturedEnvironment );
50 if(TheResult == 0)
51 {
52 Fail("The function should still return a success value even if it is "
53 "passed a LPWSTR which is not an environment block properly "
54 "acquired from GetEnvironmentStrings\n");
55 }
56
57 /* Even passing this function NULL, should still return a success value */
58 TheResult = FreeEnvironmentStrings(NULL);
59 if(TheResult == 0)
60 {
61 Fail("The function should still return a success value even if pass "
62 "NULL.\n");
63 }
64
65
66 PAL_Terminate();
67 return PASS;
68}
69
70
71
72