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: test8.c
8**
9** Purpose: Test #8 for the vsprintf function.
10**
11**
12**===================================================================*/
13
14#include <palsuite.h>
15#include "../vsprintf.h"
16
17/*
18 * Notes: memcmp is used, as is strlen.
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) != 0)
29 {
30 return(FAIL);
31 }
32
33 DoNumTest("foo %d", pos, "foo 42");
34 DoNumTest("foo %ld", 0xFFFF, "foo 65535");
35 DoNumTest("foo %hd", 0xFFFF, "foo -1");
36 DoNumTest("foo %Ld", pos, "foo 42");
37 DoI64Test("foo %I64d", l, "42", "foo 42");
38 DoNumTest("foo %3d", pos, "foo 42");
39 DoNumTest("foo %-3d", pos, "foo 42 ");
40 DoNumTest("foo %.1d", pos, "foo 42");
41 DoNumTest("foo %.3d", pos, "foo 042");
42 DoNumTest("foo %03d", pos, "foo 042");
43 DoNumTest("foo %#d", pos, "foo 42");
44 DoNumTest("foo %+d", pos, "foo +42");
45 DoNumTest("foo % d", pos, "foo 42");
46 DoNumTest("foo %+d", neg, "foo -42");
47 DoNumTest("foo % d", neg, "foo -42");
48
49
50 PAL_Terminate();
51 return PASS;
52}
53