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: test11.c (fprintf) |
8 | ** |
9 | ** Purpose: Test the unsigned int specifier (%u). |
10 | ** This test is modeled after the fprintf series. |
11 | ** |
12 | ** |
13 | **==========================================================================*/ |
14 | |
15 | #include <palsuite.h> |
16 | #include "../fprintf.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 | return(FAIL); |
30 | |
31 | DoNumTest("foo %u" , pos, "foo 42" ); |
32 | DoNumTest("foo %lu" , 0xFFFF, "foo 65535" ); |
33 | DoNumTest("foo %hu" , 0xFFFF, "foo 65535" ); |
34 | DoNumTest("foo %Lu" , pos, "foo 42" ); |
35 | DoI64Test("foo %I64u" , l, "42" , "foo 42" , "foo 42" ); |
36 | DoNumTest("foo %3u" , pos, "foo 42" ); |
37 | DoNumTest("foo %-3u" , pos, "foo 42 " ); |
38 | DoNumTest("foo %.1u" , pos, "foo 42" ); |
39 | DoNumTest("foo %.3u" , pos, "foo 042" ); |
40 | DoNumTest("foo %03u" , pos, "foo 042" ); |
41 | DoNumTest("foo %#u" , pos, "foo 42" ); |
42 | DoNumTest("foo %+u" , pos, "foo 42" ); |
43 | DoNumTest("foo % u" , pos, "foo 42" ); |
44 | DoNumTest("foo %+u" , neg, "foo 4294967254" ); |
45 | DoNumTest("foo % u" , neg, "foo 4294967254" ); |
46 | |
47 | PAL_Terminate(); |
48 | return PASS; |
49 | } |
50 | |