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 (fprintf) |
8 | ** |
9 | ** Purpose: Tests the decimal notation double specifier (%f). |
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 | |
22 | int __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 | return(FAIL); |
29 | |
30 | DoDoubleTest("foo %f" , val, "foo 2560.001000" , "foo 2560.001000" ); |
31 | DoDoubleTest("foo %lf" , val, "foo 2560.001000" , "foo 2560.001000" ); |
32 | DoDoubleTest("foo %hf" , val, "foo 2560.001000" , "foo 2560.001000" ); |
33 | DoDoubleTest("foo %Lf" , val, "foo 2560.001000" , "foo 2560.001000" ); |
34 | DoDoubleTest("foo %I64f" , val, "foo 2560.001000" , "foo 2560.001000" ); |
35 | DoDoubleTest("foo %12f" , val, "foo 2560.001000" , "foo 2560.001000" ); |
36 | DoDoubleTest("foo %-12f" , val, "foo 2560.001000 " , "foo 2560.001000 " ); |
37 | DoDoubleTest("foo %.1f" , val, "foo 2560.0" , "foo 2560.0" ); |
38 | DoDoubleTest("foo %.8f" , val, "foo 2560.00100000" , "foo 2560.00100000" ); |
39 | DoDoubleTest("foo %012f" , val, "foo 02560.001000" , "foo 02560.001000" ); |
40 | DoDoubleTest("foo %#f" , val, "foo 2560.001000" , "foo 2560.001000" ); |
41 | DoDoubleTest("foo %+f" , val, "foo +2560.001000" , "foo +2560.001000" ); |
42 | DoDoubleTest("foo % f" , val, "foo 2560.001000" , "foo 2560.001000" ); |
43 | DoDoubleTest("foo %+f" , neg, "foo -2560.001000" , "foo -2560.001000" ); |
44 | DoDoubleTest("foo % f" , neg, "foo -2560.001000" , "foo -2560.001000" ); |
45 | |
46 | PAL_Terminate(); |
47 | return PASS; |
48 | } |
49 | |