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: Test #9 for the vfprintf function. Tests the integer
10** specifier (%i).
11**
12**
13**==========================================================================*/
14
15
16
17#include <palsuite.h>
18#include "../vfprintf.h"
19
20
21
22int __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))
29 {
30 return FAIL;
31 }
32
33
34 DoNumTest("foo %i", pos, "foo 42");
35 DoNumTest("foo %li", 0xFFFF, "foo 65535");
36 DoNumTest("foo %hi", 0xFFFF, "foo -1");
37 DoNumTest("foo %Li", pos, "foo 42");
38 DoI64Test("foo %I64i", l, "42", "foo 42");
39 DoNumTest("foo %3i", pos, "foo 42");
40 DoNumTest("foo %-3i", pos, "foo 42 ");
41 DoNumTest("foo %.1i", pos, "foo 42");
42 DoNumTest("foo %.3i", pos, "foo 042");
43 DoNumTest("foo %03i", pos, "foo 042");
44 DoNumTest("foo %#i", pos, "foo 42");
45 DoNumTest("foo %+i", pos, "foo +42");
46 DoNumTest("foo % i", pos, "foo 42");
47 DoNumTest("foo %+i", neg, "foo -42");
48 DoNumTest("foo % i", neg, "foo -42");
49
50 PAL_Terminate();
51 return PASS;
52}
53
54