| 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 FormatMessageW() function |
| 10 | ** |
| 11 | ** |
| 12 | **=========================================================*/ |
| 13 | |
| 14 | #define UNICODE |
| 15 | #include <palsuite.h> |
| 16 | |
| 17 | |
| 18 | int __cdecl main(int argc, char *argv[]) { |
| 19 | |
| 20 | WCHAR TheString[] = {'P','a','l',' ','T','e','s','t','\0'}; |
| 21 | WCHAR OutBuffer[128]; |
| 22 | int ReturnResult; |
| 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 | |
| 34 | ReturnResult = FormatMessage( |
| 35 | FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ |
| 36 | TheString, /* message source */ |
| 37 | 0, /* message identifier */ |
| 38 | 0, /* language identifier */ |
| 39 | OutBuffer, /* message buffer */ |
| 40 | 1024, /* maximum size of message buffer */ |
| 41 | NULL /* array of message inserts */ |
| 42 | ); |
| 43 | |
| 44 | |
| 45 | if(ReturnResult == 0) |
| 46 | { |
| 47 | Fail("ERROR: The return value was 0, which indicates failure. " |
| 48 | "The function failed when trying to Format a simple string" |
| 49 | ", with no formatters in it." ); |
| 50 | } |
| 51 | |
| 52 | if(memcmp(OutBuffer,TheString,wcslen(OutBuffer)*2+2) != 0) |
| 53 | { |
| 54 | Fail("ERROR: The formatted string should be %s but is really %s." , |
| 55 | convertC(TheString), |
| 56 | convertC(OutBuffer)); |
| 57 | } |
| 58 | |
| 59 | PAL_Terminate(); |
| 60 | return PASS; |
| 61 | } |
| 62 | |
| 63 | |
| 64 | |