This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19 #include <stdlib.h>
20
21 #include <errno.h>
22 #include <locale.h>
23
24 #include "macros.h"
25
26 int
27 main (int argc, char *argv[])
28 {
29
30
31
32 if (setlocale (LC_ALL, "") == NULL)
33 return 1;
34
35 {
36 const char input[] = "1,";
37 char *ptr;
38 long double result;
39 errno = 0;
40 result = strtold (input, &ptr);
41 ASSERT (result == 1.0L);
42 ASSERT (ptr == input + 2);
43 ASSERT (errno == 0);
44 }
45 {
46 const char input[] = ",5";
47 char *ptr;
48 long double result;
49 errno = 0;
50 result = strtold (input, &ptr);
51 ASSERT (result == 0.5L);
52 ASSERT (ptr == input + 2);
53 ASSERT (errno == 0);
54 }
55 {
56 const char input[] = "1,5";
57 char *ptr;
58 long double result;
59 errno = 0;
60 result = strtold (input, &ptr);
61 ASSERT (result == 1.5L);
62 ASSERT (ptr == input + 3);
63 ASSERT (errno == 0);
64 }
65 {
66 const char input[] = "1.5";
67 char *ptr;
68 long double result;
69 errno = 0;
70 result = strtold (input, &ptr);
71
72
73 ASSERT ((ptr == input + 1 && result == 1.0L)
74 || (ptr == input + 3 && result == 1.5L));
75 ASSERT (errno == 0);
76 }
77 {
78 const char input[] = "123.456,789";
79 char *ptr;
80 long double result;
81 errno = 0;
82 result = strtold (input, &ptr);
83
84
85 ASSERT ((ptr == input + 3 && result == 123.0L)
86 || (ptr == input + 7 && result > 123.45L && result < 123.46L));
87 ASSERT (errno == 0);
88 }
89 {
90 const char input[] = "123,456.789";
91 char *ptr;
92 long double result;
93 errno = 0;
94 result = strtold (input, &ptr);
95 ASSERT (result > 123.45L && result < 123.46L);
96 ASSERT (ptr == input + 7);
97 ASSERT (errno == 0);
98 }
99
100 return 0;
101 }