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: test2.c
8**
9** Purpose: Test #2 for the printf function. Tests the string specifier
10** (%s).
11**
12**
13**==========================================================================*/
14
15
16#include <palsuite.h>
17#include "../printf.h"
18
19
20
21int __cdecl main(int argc, char *argv[])
22{
23
24 if (PAL_Initialize(argc, argv))
25 {
26 return FAIL;
27 }
28
29
30 DoStrTest("foo %s", "bar", "foo bar");
31 DoStrTest("foo %hs", "bar", "foo bar");
32 DoWStrTest("foo %ls", convert("bar"), "foo bar");
33 DoWStrTest("foo %ws", convert("bar"), "foo bar");
34 DoStrTest("foo %Ls", "bar", "foo bar");
35 DoStrTest("foo %I64s", "bar", "foo bar");
36 DoStrTest("foo %5s", "bar", "foo bar");
37 DoStrTest("foo %.2s", "bar", "foo ba");
38 DoStrTest("foo %5.2s", "bar", "foo ba");
39 DoStrTest("foo %-5s", "bar", "foo bar ");
40 DoStrTest("foo %05s", "bar", "foo 00bar");
41 DoStrTest("foo %s", NULL, "foo (null)");
42 DoStrTest("foo %hs", NULL, "foo (null)");
43 DoWStrTest("foo %ls", NULL, "foo (null)");
44 DoWStrTest("foo %ws", NULL, "foo (null)");
45 DoStrTest("foo %Ls", NULL, "foo (null)");
46 DoStrTest("foo %I64s", NULL, "foo (null)");
47
48 PAL_Terminate();
49 return PASS;
50}
51
52