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: test16.c
8**
9** Purpose: Tests the decimal notation double specifier (%f).
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 double val = 2560.001;
25 double neg = -2560.001;
26
27 if (PAL_Initialize(argc, argv) != 0)
28 {
29 return(FAIL);
30 }
31
32 DoDoubleTest(convert("foo %f"), val, "foo 2560.001000",
33 "foo 2560.001000");
34 DoDoubleTest(convert("foo %lf"), val, "foo 2560.001000",
35 "foo 2560.001000");
36 DoDoubleTest(convert("foo %hf"), val, "foo 2560.001000",
37 "foo 2560.001000");
38 DoDoubleTest(convert("foo %Lf"), val, "foo 2560.001000",
39 "foo 2560.001000");
40 DoDoubleTest(convert("foo %I64f"), val, "foo 2560.001000",
41 "foo 2560.001000");
42 DoDoubleTest(convert("foo %12f"), val, "foo 2560.001000",
43 "foo 2560.001000");
44 DoDoubleTest(convert("foo %-12f"), val, "foo 2560.001000 ",
45 "foo 2560.001000 ");
46 DoDoubleTest(convert("foo %.1f"), val, "foo 2560.0",
47 "foo 2560.0");
48 DoDoubleTest(convert("foo %.8f"), val, "foo 2560.00100000",
49 "foo 2560.00100000");
50 DoDoubleTest(convert("foo %012f"), val, "foo 02560.001000",
51 "foo 02560.001000");
52 DoDoubleTest(convert("foo %#f"), val, "foo 2560.001000",
53 "foo 2560.001000");
54 DoDoubleTest(convert("foo %+f"), val, "foo +2560.001000",
55 "foo +2560.001000");
56 DoDoubleTest(convert("foo % f"), val, "foo 2560.001000",
57 "foo 2560.001000");
58 DoDoubleTest(convert("foo %+f"), neg, "foo -2560.001000",
59 "foo -2560.001000");
60 DoDoubleTest(convert("foo % f"), neg, "foo -2560.001000",
61 "foo -2560.001000");
62
63 PAL_Terminate();
64 return PASS;
65}
66