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: test19.c |
8 | ** |
9 | ** Purpose: Test #19 for the vsprintf function. |
10 | ** |
11 | ** |
12 | **===================================================================*/ |
13 | |
14 | #include <palsuite.h> |
15 | #include "../vsprintf.h" |
16 | |
17 | /* |
18 | * Notes: memcmp is used, as is strlen. |
19 | */ |
20 | |
21 | int __cdecl main(int argc, char *argv[]) |
22 | { |
23 | |
24 | if (PAL_Initialize(argc, argv) != 0) |
25 | { |
26 | return(FAIL); |
27 | } |
28 | |
29 | |
30 | DoArgumentPrecTest("%.*s" , 2, (void*)"bar" , "bar" , "ba" , "ba" ); |
31 | DoArgumentPrecTest("%.*S" , 2, (void*)convert("bar" ), "bar" , "ba" , "ba" ); |
32 | DoArgumentPrecTest("%.*c" , 0, (void*)'a', "a" , "a" , "a" ); |
33 | DoArgumentPrecTest("%.*c" , 4, (void*)'a', "a" , "a" , "a" ); |
34 | DoArgumentPrecTest("%.*C" , 0, (void*)'a', "a" , "a" , "a" ); |
35 | DoArgumentPrecTest("%.*C" , 4, (void*)'a', "a" , "a" , "a" ); |
36 | DoArgumentPrecTest("%.*d" , 1, (void*)42, "42" , "42" , "42" ); |
37 | DoArgumentPrecTest("%.*d" , 3, (void*)42, "42" , "042" , "042" ); |
38 | DoArgumentPrecTest("%.*i" , 1, (void*)42, "42" , "42" , "42" ); |
39 | DoArgumentPrecTest("%.*i" , 3, (void*)42, "42" , "042" , "042" ); |
40 | DoArgumentPrecTest("%.*o" , 1, (void*)42, "42" , "52" , "52" ); |
41 | DoArgumentPrecTest("%.*o" , 3, (void*)42, "42" , "052" , "052" ); |
42 | DoArgumentPrecTest("%.*u" , 1, (void*)42, "42" , "42" , "42" ); |
43 | DoArgumentPrecTest("%.*u" , 3, (void*)42, "42" , "042" , "042" ); |
44 | DoArgumentPrecTest("%.*x" , 1, (void*)0x42, "0x42" , "42" , "42" ); |
45 | DoArgumentPrecTest("%.*x" , 3, (void*)0x42, "0x42" , "042" , "042" ); |
46 | DoArgumentPrecTest("%.*X" , 1, (void*)0x42, "0x42" , "42" , "42" ); |
47 | DoArgumentPrecTest("%.*X" , 3, (void*)0x42, "0x42" , "042" , "042" ); |
48 | |
49 | |
50 | DoArgumentPrecDoubleTest("%.*e" , 1, 2.01, "2.0e+000" , "2.0e+00" ); |
51 | DoArgumentPrecDoubleTest("%.*e" , 3, 2.01, "2.010e+000" , "2.010e+00" ); |
52 | DoArgumentPrecDoubleTest("%.*E" , 1, 2.01, "2.0E+000" , "2.0E+00" ); |
53 | DoArgumentPrecDoubleTest("%.*E" , 3, 2.01, "2.010E+000" , "2.010E+00" ); |
54 | DoArgumentPrecDoubleTest("%.*f" , 1, 2.01, "2.0" , "2.0" ); |
55 | DoArgumentPrecDoubleTest("%.*f" , 3, 2.01, "2.010" , "2.010" ); |
56 | DoArgumentPrecDoubleTest("%.*g" , 1, 256.01, "3e+002" , "3e+02" ); |
57 | DoArgumentPrecDoubleTest("%.*g" , 3, 256.01, "256" , "256" ); |
58 | DoArgumentPrecDoubleTest("%.*g" , 4, 256.01, "256" , "256" ); |
59 | DoArgumentPrecDoubleTest("%.*g" , 6, 256.01, "256.01" , "256.01" ); |
60 | DoArgumentPrecDoubleTest("%.*G" , 1, 256.01, "3E+002" , "3E+02" ); |
61 | DoArgumentPrecDoubleTest("%.*G" , 3, 256.01, "256" , "256" ); |
62 | DoArgumentPrecDoubleTest("%.*G" , 4, 256.01, "256" , "256" ); |
63 | DoArgumentPrecDoubleTest("%.*G" , 6, 256.01, "256.01" , "256.01" ); |
64 | |
65 | PAL_Terminate(); |
66 | return PASS; |
67 | } |
68 | |