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: test9.c |
8 | ** |
9 | ** Purpose: Tests the integer specifier (%i). |
10 | ** This test is modeled after the sprintf series. |
11 | ** |
12 | ** |
13 | **==========================================================================*/ |
14 | |
15 | #include <palsuite.h> |
16 | #include "../fwprintf.h" |
17 | |
18 | /* |
19 | * Depends on memcmp, strlen, fopen, fseek and fgets. |
20 | */ |
21 | |
22 | int __cdecl main(int argc, char *argv[]) |
23 | { |
24 | int neg = -42; |
25 | int pos = 42; |
26 | INT64 l = 42; |
27 | |
28 | if (PAL_Initialize(argc, argv) != 0) |
29 | { |
30 | return(FAIL); |
31 | } |
32 | |
33 | DoNumTest(convert("foo %i" ), pos, "foo 42" ); |
34 | DoNumTest(convert("foo %li" ), 0xFFFF, "foo 65535" ); |
35 | DoNumTest(convert("foo %hi" ), 0xFFFF, "foo -1" ); |
36 | DoNumTest(convert("foo %Li" ), pos, "foo 42" ); |
37 | DoI64Test(convert("foo %I64i" ), l, "42" , "foo 42" , "foo 42" ); |
38 | DoNumTest(convert("foo %3i" ), pos, "foo 42" ); |
39 | DoNumTest(convert("foo %-3i" ), pos, "foo 42 " ); |
40 | DoNumTest(convert("foo %.1i" ), pos, "foo 42" ); |
41 | DoNumTest(convert("foo %.3i" ), pos, "foo 042" ); |
42 | DoNumTest(convert("foo %03i" ), pos, "foo 042" ); |
43 | DoNumTest(convert("foo %#i" ), pos, "foo 42" ); |
44 | DoNumTest(convert("foo %+i" ), pos, "foo +42" ); |
45 | DoNumTest(convert("foo % i" ), pos, "foo 42" ); |
46 | DoNumTest(convert("foo %+i" ), neg, "foo -42" ); |
47 | DoNumTest(convert("foo % i" ), neg, "foo -42" ); |
48 | |
49 | PAL_Terminate(); |
50 | return PASS; |
51 | } |
52 | |