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 strtod with overflows
10**
11**
12**===================================================================*/
13
14#include <palsuite.h>
15
16int __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 double result;
24
25
26 if (PAL_Initialize(argc,argv))
27 {
28 return FAIL;
29 }
30
31 result = strtod(PosStr, NULL);
32
33 if (result != HugeVal)
34 {
35 Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n",
36 PosStr, result, HugeVal);
37 }
38
39 result = strtod(NegStr, NULL);
40
41 if (result != -HugeVal)
42 {
43 Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n",
44 NegStr, result, -HugeVal);
45 }
46
47 PAL_Terminate();
48
49 return PASS;
50}
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66