| 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 GetCommandLineW() function |
| 10 | ** |
| 11 | ** |
| 12 | **=========================================================*/ |
| 13 | |
| 14 | #define UNICODE |
| 15 | #include <palsuite.h> |
| 16 | |
| 17 | int __cdecl main(int argc, char *argv[]) |
| 18 | { |
| 19 | |
| 20 | LPWSTR TheResult = NULL; |
| 21 | WCHAR *CommandLine; |
| 22 | int i; |
| 23 | WCHAR * p; |
| 24 | |
| 25 | /* |
| 26 | * Initialize the PAL and return FAILURE if this fails |
| 27 | */ |
| 28 | |
| 29 | if(0 != (PAL_Initialize(argc, argv))) |
| 30 | { |
| 31 | return FAIL; |
| 32 | } |
| 33 | |
| 34 | CommandLine = (WCHAR*)malloc(1024); |
| 35 | wcscpy(CommandLine,convert(argv[0])); |
| 36 | |
| 37 | for(i=1;i<argc;++i) |
| 38 | { |
| 39 | wcscat(CommandLine,convert(" " )); |
| 40 | wcscat(CommandLine,convert(argv[i])); |
| 41 | } |
| 42 | |
| 43 | TheResult = GetCommandLine(); |
| 44 | |
| 45 | /* If it is NULL, it failed. */ |
| 46 | if(TheResult == NULL) |
| 47 | { |
| 48 | Fail("ERROR: The command line returned was NULL -- but should be " |
| 49 | "a LPWSTR." ); |
| 50 | } |
| 51 | |
| 52 | // It's ok that if there is trailing white spaces in "TheResult" |
| 53 | // Let's trim them. |
| 54 | p = TheResult + wcslen(TheResult) - 1; |
| 55 | while (* p == L' ' || * p == L'\t') { printf("%c\n" , *p); * p-- = 0 ; } |
| 56 | |
| 57 | if(memcmp(TheResult,CommandLine,wcslen(TheResult)*2+2) != 0) |
| 58 | { |
| 59 | Fail("ERROR: The command line returned was %s instead of %s " |
| 60 | "which was the command.\n" , |
| 61 | convertC(TheResult), convertC(CommandLine)); |
| 62 | } |
| 63 | |
| 64 | free(CommandLine); |
| 65 | |
| 66 | PAL_Terminate(); |
| 67 | return PASS; |
| 68 | |
| 69 | } |
| 70 | |
| 71 | |
| 72 | |