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: Tests the string specifier (%s).
10** This test is modeled after the sprintf series.
11**
12**
13**==========================================================================*/
14
15#include <palsuite.h>
16#include "../fwprintf.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 {
27 return(FAIL);
28 }
29
30 DoWStrTest(convert("foo %s"), convert("bar"), "foo bar");
31 DoStrTest(convert("foo %hs"), "bar", "foo bar");
32 DoWStrTest(convert("foo %ls"), convert("bar"), "foo bar");
33 DoWStrTest(convert("foo %ws"), convert("bar"), "foo bar");
34 DoWStrTest(convert("foo %Ls"), convert("bar"), "foo bar");
35 DoWStrTest(convert("foo %I64s"), convert("bar"), "foo bar");
36 DoWStrTest(convert("foo %5s"), convert("bar"), "foo bar");
37 DoWStrTest(convert("foo %.2s"), convert("bar"), "foo ba");
38 DoWStrTest(convert("foo %5.2s"), convert("bar"), "foo ba");
39 DoWStrTest(convert("foo %-5s"), convert("bar"), "foo bar ");
40 DoWStrTest(convert("foo %05s"), convert("bar"), "foo 00bar");
41 DoWStrTest(convert("foo %s"), NULL, "foo (null)");
42 DoStrTest(convert("foo %hs"), NULL, "foo (null)");
43 DoWStrTest(convert("foo %ls"), NULL, "foo (null)");
44 DoWStrTest(convert("foo %ws"), NULL, "foo (null)");
45 DoWStrTest(convert("foo %Ls"), NULL, "foo (null)");
46 DoWStrTest(convert("foo %I64s"), NULL, "foo (null)");
47
48 PAL_Terminate();
49 return PASS;
50}
51
52