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 swprintf with compact format doubles (uppercase)
10**
11**
12**==========================================================================*/
13
14
15
16#include <palsuite.h>
17#include "../swprintf.h"
18
19/*
20 * Uses memcmp & wcslen
21 */
22
23int __cdecl main(int argc, char *argv[])
24{
25 double val = 2560.001;
26 double neg = -2560.001;
27
28 if (PAL_Initialize(argc, argv) != 0)
29 {
30 return FAIL;
31 }
32
33
34 DoDoubleTest(convert("foo %G"), val, convert("foo 2560"),
35 convert("foo 2560"));
36 DoDoubleTest(convert("foo %lG"), val, convert("foo 2560"),
37 convert("foo 2560"));
38 DoDoubleTest(convert("foo %hG"), val, convert("foo 2560"),
39 convert("foo 2560"));
40 DoDoubleTest(convert("foo %LG"), val, convert("foo 2560"),
41 convert("foo 2560"));
42 DoDoubleTest(convert("foo %I64G"), val, convert("foo 2560"),
43 convert("foo 2560"));
44 DoDoubleTest(convert("foo %5G"), val, convert("foo 2560"),
45 convert("foo 2560"));
46 DoDoubleTest(convert("foo %-5G"), val, convert("foo 2560 "),
47 convert("foo 2560 "));
48 DoDoubleTest(convert("foo %.1G"), val, convert("foo 3E+003"),
49 convert("foo 3E+03"));
50 DoDoubleTest(convert("foo %.2G"), val, convert("foo 2.6E+003"),
51 convert("foo 2.6E+03"));
52 DoDoubleTest(convert("foo %.12G"), val, convert("foo 2560.001"),
53 convert("foo 2560.001"));
54 DoDoubleTest(convert("foo %06G"), val, convert("foo 002560"),
55 convert("foo 002560"));
56 DoDoubleTest(convert("foo %#G"), val, convert("foo 2560.00"),
57 convert("foo 2560.00"));
58 DoDoubleTest(convert("foo %+G"), val, convert("foo +2560"),
59 convert("foo +2560"));
60 DoDoubleTest(convert("foo % G"), val, convert("foo 2560"),
61 convert("foo 2560"));
62 DoDoubleTest(convert("foo %+G"), neg, convert("foo -2560"),
63 convert("foo -2560"));
64 DoDoubleTest(convert("foo % G"), neg, convert("foo -2560"),
65 convert("foo -2560"));
66
67 PAL_Terminate();
68 return PASS;
69}
70