| 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: Tests swprintf with hex numbers (lowercase) |
| 10 | ** |
| 11 | ** |
| 12 | **==========================================================================*/ |
| 13 | |
| 14 | |
| 15 | |
| 16 | #include <palsuite.h> |
| 17 | #include "../swprintf.h" |
| 18 | |
| 19 | /* |
| 20 | * Uses memcmp & wcslen |
| 21 | */ |
| 22 | |
| 23 | int __cdecl main(int argc, char *argv[]) |
| 24 | { |
| 25 | int neg = -42; |
| 26 | int pos = 0x1234ab; |
| 27 | INT64 l = I64(0x1234567887654321); |
| 28 | |
| 29 | if (PAL_Initialize(argc, argv) != 0) |
| 30 | { |
| 31 | return FAIL; |
| 32 | } |
| 33 | |
| 34 | |
| 35 | DoNumTest(convert("foo %x" ), pos, convert("foo 1234ab" )); |
| 36 | DoNumTest(convert("foo %lx" ), pos, convert("foo 1234ab" )); |
| 37 | DoNumTest(convert("foo %hx" ), pos, convert("foo 34ab" )); |
| 38 | DoNumTest(convert("foo %Lx" ), pos, convert("foo 1234ab" )); |
| 39 | DoI64Test(convert("foo %I64x" ), l, "0x1234567887654321" , |
| 40 | convert("foo 1234567887654321" )); |
| 41 | DoNumTest(convert("foo %7x" ), pos, convert("foo 1234ab" )); |
| 42 | DoNumTest(convert("foo %-7x" ), pos, convert("foo 1234ab " )); |
| 43 | DoNumTest(convert("foo %.1x" ), pos, convert("foo 1234ab" )); |
| 44 | DoNumTest(convert("foo %.7x" ), pos, convert("foo 01234ab" )); |
| 45 | DoNumTest(convert("foo %07x" ), pos, convert("foo 01234ab" )); |
| 46 | DoNumTest(convert("foo %#x" ), pos, convert("foo 0x1234ab" )); |
| 47 | DoNumTest(convert("foo %+x" ), pos, convert("foo 1234ab" )); |
| 48 | DoNumTest(convert("foo % x" ), pos, convert("foo 1234ab" )); |
| 49 | DoNumTest(convert("foo %+x" ), neg, convert("foo ffffffd6" )); |
| 50 | DoNumTest(convert("foo % x" ), neg, convert("foo ffffffd6" )); |
| 51 | |
| 52 | PAL_Terminate(); |
| 53 | return PASS; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |