This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "vasnprintf.h"
22
23 #include <locale.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "macros.h"
28
29 int
30 main (int argc, char *argv[])
31 {
32
33 if (setlocale (LC_ALL, "") == NULL)
34 return 1;
35
36
37 {
38 size_t length;
39 char *result = asnprintf (NULL, &length, "%.1a", 1.0);
40 ASSERT (result != NULL);
41 ASSERT (strcmp (result, "0x1,0p+0") == 0
42 || strcmp (result, "0x2,0p-1") == 0
43 || strcmp (result, "0x4,0p-2") == 0
44 || strcmp (result, "0x8,0p-3") == 0);
45 ASSERT (length == strlen (result));
46 free (result);
47 }
48
49
50 {
51 size_t length;
52 char *result = asnprintf (NULL, &length, "%.1La", 1.0L);
53 ASSERT (result != NULL);
54 ASSERT (strcmp (result, "0x1,0p+0") == 0
55 || strcmp (result, "0x2,0p-1") == 0
56 || strcmp (result, "0x4,0p-2") == 0
57 || strcmp (result, "0x8,0p-3") == 0);
58 ASSERT (length == strlen (result));
59 free (result);
60 }
61
62 return 0;
63 }