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: test2.c |
8 | ** |
9 | ** Purpose: Tests wcstod with overflows |
10 | ** |
11 | ** |
12 | **===================================================================*/ |
13 | |
14 | #include <palsuite.h> |
15 | |
16 | int __cdecl main(int argc, char **argv) |
17 | { |
18 | /* Representation of positive infinty for a IEEE 64-bit double */ |
19 | INT64 PosInifity = (INT64)(0x7ff00000) << 32; |
20 | double HugeVal = *(double*) &PosInifity; |
21 | char *PosStr = "1E+10000" ; |
22 | char *NegStr = "-1E+10000" ; |
23 | WCHAR *wideStr; |
24 | double result; |
25 | |
26 | |
27 | if (PAL_Initialize(argc,argv)) |
28 | { |
29 | return FAIL; |
30 | } |
31 | |
32 | wideStr = convert(PosStr); |
33 | result = wcstod(wideStr, NULL); |
34 | free(wideStr); |
35 | |
36 | if (result != HugeVal) |
37 | { |
38 | Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n" , |
39 | PosStr, result, HugeVal); |
40 | } |
41 | |
42 | |
43 | |
44 | wideStr = convert(NegStr); |
45 | result = wcstod(wideStr, NULL); |
46 | free(wideStr); |
47 | |
48 | if (result != -HugeVal) |
49 | { |
50 | Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n" , |
51 | NegStr, result, -HugeVal); |
52 | } |
53 | |
54 | |
55 | PAL_Terminate(); |
56 | |
57 | return PASS; |
58 | } |
59 | |
60 | |