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 "astrxfrm.h"
22
23 #include <locale.h>
24 #include <string.h>
25
26 #include "macros.h"
27
28 int
29 main ()
30 {
31 const char input[] = "B\303\266se B\303\274bchen";
32 char *expected_transform;
33
34 setlocale (LC_ALL, "de_DE.UTF-8");
35
36
37 {
38 size_t length = 0;
39 char *transform = astrxfrm (input, NULL, &length);
40 ASSERT (transform != NULL);
41 ASSERT (length == strlen (transform) + 1);
42 expected_transform = transform;
43 }
44
45
46 {
47 size_t length = 100;
48 char *transform = astrxfrm (input, NULL, &length);
49 ASSERT (transform != NULL);
50 ASSERT (strcmp (transform, expected_transform) == 0);
51 ASSERT (length == strlen (transform) + 1);
52 free (transform);
53 }
54
55
56 {
57 char buf[1];
58 size_t length = 0;
59 char *transform;
60 buf[0] = '@';
61 transform = astrxfrm (input, buf, &length);
62 ASSERT (transform != NULL);
63 ASSERT (transform != buf);
64 ASSERT (strcmp (transform, expected_transform) == 0);
65 ASSERT (length == strlen (transform) + 1);
66 ASSERT (buf[0] == '@');
67 free (transform);
68 }
69
70
71 {
72 char buf[3];
73 size_t length = sizeof (buf) - 1;
74 char *transform;
75 buf[sizeof (buf) - 1] = '@';
76 transform = astrxfrm (input, buf, &length);
77 ASSERT (transform != NULL);
78 ASSERT (transform != buf);
79 ASSERT (strcmp (transform, expected_transform) == 0);
80 ASSERT (length == strlen (transform) + 1);
81 ASSERT (buf[sizeof (buf) - 1] == '@');
82 free (transform);
83 }
84
85
86 {
87 char buf[200];
88 size_t length = sizeof (buf) - 1;
89 char *transform;
90 buf[sizeof (buf) - 1] = '@';
91 transform = astrxfrm (input, buf, &length);
92 ASSERT (transform != NULL);
93 ASSERT (transform == buf);
94 ASSERT (strcmp (transform, expected_transform) == 0);
95 ASSERT (length == strlen (transform) + 1);
96 ASSERT (buf[sizeof (buf) - 1] == '@');
97 }
98
99 free (expected_transform);
100
101 return 0;
102 }