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: test17.c (fprintf) |
8 | ** |
9 | ** Purpose: Tests the lowercase shorthand notation double specifier (%g). |
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 %g" , val, "foo 2560" , "foo 2560" ); |
31 | DoDoubleTest("foo %lg" , val, "foo 2560" , "foo 2560" ); |
32 | DoDoubleTest("foo %hg" , val, "foo 2560" , "foo 2560" ); |
33 | DoDoubleTest("foo %Lg" , val, "foo 2560" , "foo 2560" ); |
34 | DoDoubleTest("foo %I64g" , val, "foo 2560" , "foo 2560" ); |
35 | DoDoubleTest("foo %5g" , val, "foo 2560" , "foo 2560" ); |
36 | DoDoubleTest("foo %-5g" , val, "foo 2560 " , "foo 2560 " ); |
37 | DoDoubleTest("foo %.1g" , val, "foo 3e+003" , "foo 3e+03" ); |
38 | DoDoubleTest("foo %.2g" , val, "foo 2.6e+003" , "foo 2.6e+03" ); |
39 | DoDoubleTest("foo %.12g" , val, "foo 2560.001" , "foo 2560.001" ); |
40 | DoDoubleTest("foo %06g" , val, "foo 002560" , "foo 002560" ); |
41 | DoDoubleTest("foo %#g" , val, "foo 2560.00" , "foo 2560.00" ); |
42 | DoDoubleTest("foo %+g" , val, "foo +2560" , "foo +2560" ); |
43 | DoDoubleTest("foo % g" , val, "foo 2560" , "foo 2560" ); |
44 | DoDoubleTest("foo %+g" , neg, "foo -2560" , "foo -2560" ); |
45 | DoDoubleTest("foo % g" , neg, "foo -2560" , "foo -2560" ); |
46 | |
47 | PAL_Terminate(); |
48 | return PASS; |
49 | } |
50 | |