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 | WCHAR OutBuffer[1024]; |
18 | |
19 | int __cdecl main(int argc, char *argv[]) |
20 | { |
21 | |
22 | WCHAR * TheString; |
23 | WCHAR* TheArray[3]; |
24 | int ReturnResult; |
25 | |
26 | /* |
27 | * Initialize the PAL and return FAILURE if this fails |
28 | */ |
29 | |
30 | if(0 != (PAL_Initialize(argc, argv))) |
31 | { |
32 | return FAIL; |
33 | } |
34 | |
35 | TheString = convert("Pal %1 %2 %3 Testing" ); |
36 | TheArray[0] = convert("Foo" ); |
37 | TheArray[1] = convert("Bar" ); |
38 | TheArray[2] = convert("FooBar" ); |
39 | |
40 | /* This should just use the 3 strings in the array to replace |
41 | inserts in the given string. |
42 | */ |
43 | |
44 | ReturnResult = FormatMessage( |
45 | FORMAT_MESSAGE_FROM_STRING | |
46 | FORMAT_MESSAGE_ARGUMENT_ARRAY, /* source and processing options */ |
47 | TheString, /* message source */ |
48 | 0, /* message identifier */ |
49 | 0, /* language identifier */ |
50 | OutBuffer, /* message buffer */ |
51 | 1024, /* maximum size of message buffer */ |
52 | (va_list *) TheArray /* array of message inserts */ |
53 | ); |
54 | |
55 | if(ReturnResult == 0) |
56 | { |
57 | Fail("ERROR: The return value was 0, which indicates failure. " |
58 | "The function failed when trying to Format a simple string, " |
59 | "usin gthe ARGUMENT_ARRAY flag." ); |
60 | } |
61 | |
62 | if(memcmp(OutBuffer, |
63 | convert("Pal Foo Bar FooBar Testing" ), |
64 | wcslen(OutBuffer)*2+2) != 0) |
65 | { |
66 | Fail("ERROR: Since the FORMAT_MESSAGE_ARGUMENT_ARRAY flag was set, " |
67 | "the result should have been 'Pal Foo Bar FooBar Testing' but was" |
68 | " really '%s'." ,convertC(OutBuffer)); |
69 | } |
70 | |
71 | |
72 | PAL_Terminate(); |
73 | return PASS; |
74 | |
75 | } |
76 | |
77 | |
78 | |