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: test12.c |
8 | ** |
9 | ** Purpose: Test #12 for the vswprintf function. |
10 | ** |
11 | ** |
12 | **===================================================================*/ |
13 | |
14 | #include <palsuite.h> |
15 | #include "../vswprintf.h" |
16 | |
17 | /* memcmp is used to verify the results, so this test is dependent on it. */ |
18 | /* ditto with wcslen */ |
19 | |
20 | int __cdecl main(int argc, char *argv[]) |
21 | { |
22 | int neg = -42; |
23 | int pos = 0x1234ab; |
24 | INT64 l = I64(0x1234567887654321); |
25 | |
26 | if (PAL_Initialize(argc, argv) != 0) |
27 | return(FAIL); |
28 | |
29 | DoNumTest(convert("foo %x" ), pos, convert("foo 1234ab" )); |
30 | DoNumTest(convert("foo %lx" ), pos, convert("foo 1234ab" )); |
31 | DoNumTest(convert("foo %hx" ), pos, convert("foo 34ab" )); |
32 | DoNumTest(convert("foo %Lx" ), pos, convert("foo 1234ab" )); |
33 | DoI64NumTest(convert("foo %I64x" ), l, "0x1234567887654321" , |
34 | convert("foo 1234567887654321" )); |
35 | DoNumTest(convert("foo %7x" ), pos, convert("foo 1234ab" )); |
36 | DoNumTest(convert("foo %-7x" ), pos, convert("foo 1234ab " )); |
37 | DoNumTest(convert("foo %.1x" ), pos, convert("foo 1234ab" )); |
38 | DoNumTest(convert("foo %.7x" ), pos, convert("foo 01234ab" )); |
39 | DoNumTest(convert("foo %07x" ), pos, convert("foo 01234ab" )); |
40 | DoNumTest(convert("foo %#x" ), pos, convert("foo 0x1234ab" )); |
41 | DoNumTest(convert("foo %+x" ), pos, convert("foo 1234ab" )); |
42 | DoNumTest(convert("foo % x" ), pos, convert("foo 1234ab" )); |
43 | DoNumTest(convert("foo %+x" ), neg, convert("foo ffffffd6" )); |
44 | DoNumTest(convert("foo % x" ), neg, convert("foo ffffffd6" )); |
45 | |
46 | PAL_Terminate(); |
47 | return PASS; |
48 | } |
49 | |