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 (fprintf)
8**
9** Purpose: Tests the string specifier (%s).
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
22int __cdecl main(int argc, char *argv[])
23{
24
25 if (PAL_Initialize(argc, argv) != 0)
26 return(FAIL);
27
28 DoStrTest("foo %s", "bar", "foo bar");
29 DoStrTest("foo %hs", "bar", "foo bar");
30 DoWStrTest("foo %ls", convert("bar"), "foo bar");
31 DoWStrTest("foo %ws", convert("bar"), "foo bar");
32 DoStrTest("foo %Ls", "bar", "foo bar");
33 DoStrTest("foo %I64s", "bar", "foo bar");
34 DoStrTest("foo %5s", "bar", "foo bar");
35 DoStrTest("foo %.2s", "bar", "foo ba");
36 DoStrTest("foo %5.2s", "bar", "foo ba");
37 DoStrTest("foo %-5s", "bar", "foo bar ");
38 DoStrTest("foo %05s", "bar", "foo 00bar");
39 DoStrTest("foo %s", NULL, "foo (null)");
40 DoStrTest("foo %hs", NULL, "foo (null)");
41 DoWStrTest("foo %ls", NULL, "foo (null)");
42 DoWStrTest("foo %ws", NULL, "foo (null)");
43 DoStrTest("foo %Ls", NULL, "foo (null)");
44 DoStrTest("foo %I64s", NULL, "foo (null)");
45
46 PAL_Terminate();
47 return PASS;
48}
49
50