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 |
8 | ** |
9 | ** Purpose: Test #17 for the vswprintf function. |
10 | ** |
11 | ** |
12 | **===================================================================*/ |
13 | |
14 | #include <palsuite.h> |
15 | #include "../vswprintf.h" |
16 | |
17 | /* memcmp is used to verify the results, so this test is dependent on it. */ |
18 | /* ditto with wcslen */ |
19 | |
20 | int __cdecl main(int argc, char *argv[]) |
21 | { |
22 | double val = 2560.001; |
23 | double neg = -2560.001; |
24 | |
25 | if (PAL_Initialize(argc, argv) != 0) |
26 | return(FAIL); |
27 | |
28 | DoDoubleTest(convert("foo %g" ), val, convert("foo 2560" ), |
29 | convert("foo 2560" )); |
30 | DoDoubleTest(convert("foo %lg" ), val, convert("foo 2560" ), |
31 | convert("foo 2560" )); |
32 | DoDoubleTest(convert("foo %hg" ), val, convert("foo 2560" ), |
33 | convert("foo 2560" )); |
34 | DoDoubleTest(convert("foo %Lg" ), val, convert("foo 2560" ), |
35 | convert("foo 2560" )); |
36 | DoDoubleTest(convert("foo %I64g" ), val, convert("foo 2560" ), |
37 | convert("foo 2560" )); |
38 | DoDoubleTest(convert("foo %5g" ), val, convert("foo 2560" ), |
39 | convert("foo 2560" )); |
40 | DoDoubleTest(convert("foo %-5g" ), val, convert("foo 2560 " ), |
41 | convert("foo 2560 " )); |
42 | DoDoubleTest(convert("foo %.1g" ), val, convert("foo 3e+003" ), |
43 | convert("foo 3e+03" )); |
44 | DoDoubleTest(convert("foo %.2g" ), val, convert("foo 2.6e+003" ), |
45 | convert("foo 2.6e+03" )); |
46 | DoDoubleTest(convert("foo %.12g" ), val, convert("foo 2560.001" ), |
47 | convert("foo 2560.001" )); |
48 | DoDoubleTest(convert("foo %06g" ), val, convert("foo 002560" ), |
49 | convert("foo 002560" )); |
50 | DoDoubleTest(convert("foo %#g" ), val, convert("foo 2560.00" ), |
51 | convert("foo 2560.00" )); |
52 | DoDoubleTest(convert("foo %+g" ), val, convert("foo +2560" ), |
53 | convert("foo +2560" )); |
54 | DoDoubleTest(convert("foo % g" ), val, convert("foo 2560" ), |
55 | convert("foo 2560" )); |
56 | DoDoubleTest(convert("foo %+g" ), neg, convert("foo -2560" ), |
57 | convert("foo -2560" )); |
58 | DoDoubleTest(convert("foo % g" ), neg, convert("foo -2560" ), |
59 | convert("foo -2560" )); |
60 | |
61 | PAL_Terminate(); |
62 | return PASS; |
63 | } |
64 | |