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 GetEnvironmentVariable() function |
10 | ** |
11 | ** |
12 | **=========================================================*/ |
13 | |
14 | #define UNICODE |
15 | |
16 | #include <palsuite.h> |
17 | |
18 | #define SMALL_BUFFER_SIZE 1 |
19 | |
20 | int __cdecl main(int argc, char *argv[]) |
21 | { |
22 | |
23 | WCHAR pSmallBuffer[SMALL_BUFFER_SIZE]; |
24 | |
25 | /* A place to stash the returned values */ |
26 | int ReturnValueForSmallBuffer; |
27 | |
28 | /* |
29 | * Initialize the PAL and return FAILURE if this fails |
30 | */ |
31 | |
32 | if(0 != (PAL_Initialize(argc, argv))) |
33 | { |
34 | return FAIL; |
35 | } |
36 | |
37 | /* PATH won't fit in this buffer, it should return how many characters |
38 | it needs |
39 | */ |
40 | |
41 | ReturnValueForSmallBuffer = GetEnvironmentVariable(convert("PATH" ), |
42 | pSmallBuffer, |
43 | SMALL_BUFFER_SIZE); |
44 | |
45 | if(ReturnValueForSmallBuffer <= 0) |
46 | { |
47 | Fail("The return value was %d when it should have been greater " |
48 | "than 0. This should return the number of characters needed " |
49 | "to contained the contents of PATH in a buffer.\n" , |
50 | ReturnValueForSmallBuffer); |
51 | } |
52 | |
53 | PAL_Terminate(); |
54 | return PASS; |
55 | } |
56 | |
57 | |