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: test5.c
8**
9** Purpose: Test #5 for the vfprintf function. Tests the count specifier (%n).
10**
11**
12**==========================================================================*/
13
14
15
16#include <palsuite.h>
17#include "../vfprintf.h"
18
19
20
21
22int __cdecl main(int argc, char *argv[])
23{
24 char *longStr =
25 "really-long-string-that-just-keeps-going-on-and-on-and-on.."
26 "..................useless-filler.................................."
27 "..................useless-filler.................................."
28 "..................useless-filler.................................."
29 "%n bar";
30 char *longResult =
31 "really-long-string-that-just-keeps-going-on-and-on-and-on.."
32 "..................useless-filler.................................."
33 "..................useless-filler.................................."
34 "..................useless-filler.................................."
35 " bar";
36
37 if (PAL_Initialize(argc, argv))
38 {
39 return FAIL;
40 }
41
42 DoCountTest("foo %n bar", 4, "foo bar");
43 DoCountTest(longStr, 257, longResult);
44 DoCountTest("fo%n bar", 2, "fo bar");
45 DoCountTest("%n ", 0, " ");
46 DoCountTest("foo %#n bar", 4, "foo bar");
47 DoCountTest("foo % n bar", 4, "foo bar");
48 DoCountTest("foo %+n bar", 4, "foo bar");
49 DoCountTest("foo %-n bar", 4, "foo bar");
50 DoCountTest("foo %0n bar", 4, "foo bar");
51 DoShortCountTest("foo %hn bar", 4, "foo bar");
52 DoCountTest("foo %ln bar", 4, "foo bar");
53 DoCountTest("foo %Ln bar", 4, "foo bar");
54 DoCountTest("foo %I64n bar", 4, "foo bar");
55 DoCountTest("foo %20.3n bar", 4, "foo bar");
56
57 PAL_Terminate();
58
59 return PASS;
60}
61