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: test18.c
8**
9** Purpose: Tests the uppercase shorthand notation double specifier (%G).
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 %G"), val, "foo 2560", "foo 2560");
33 DoDoubleTest(convert("foo %lG"), val, "foo 2560", "foo 2560");
34 DoDoubleTest(convert("foo %hG"), val, "foo 2560", "foo 2560");
35 DoDoubleTest(convert("foo %LG"), val, "foo 2560", "foo 2560");
36 DoDoubleTest(convert("foo %I64G"), val, "foo 2560", "foo 2560");
37 DoDoubleTest(convert("foo %5G"), val, "foo 2560", "foo 2560");
38 DoDoubleTest(convert("foo %-5G"), val, "foo 2560 ", "foo 2560 ");
39 DoDoubleTest(convert("foo %.1G"), val, "foo 3E+003", "foo 3E+03");
40 DoDoubleTest(convert("foo %.2G"), val, "foo 2.6E+003", "foo 2.6E+03");
41 DoDoubleTest(convert("foo %.12G"), val, "foo 2560.001", "foo 2560.001");
42 DoDoubleTest(convert("foo %06G"), val, "foo 002560", "foo 002560");
43 DoDoubleTest(convert("foo %#G"), val, "foo 2560.00", "foo 2560.00");
44 DoDoubleTest(convert("foo %+G"), val, "foo +2560", "foo +2560");
45 DoDoubleTest(convert("foo % G"), val, "foo 2560", "foo 2560");
46 DoDoubleTest(convert("foo %+G"), neg, "foo -2560", "foo -2560");
47 DoDoubleTest(convert("foo % G"), neg, "foo -2560", "foo -2560");
48
49 PAL_Terminate();
50 return PASS;
51}
52