This source file includes following definitions.
- test_function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 static void
20 test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
21 {
22 char buf[8];
23 int size;
24
25
26
27 for (size = 0; size <= 8; size++)
28 {
29 size_t length = size;
30 char *result = my_asnprintf (NULL, &length, "%d", 12345);
31 ASSERT (result != NULL);
32 ASSERT (strcmp (result, "12345") == 0);
33 ASSERT (length == 5);
34 free (result);
35 }
36
37 for (size = 0; size <= 8; size++)
38 {
39 size_t length;
40 char *result;
41
42 memcpy (buf, "DEADBEEF", 8);
43 length = size;
44 result = my_asnprintf (buf, &length, "%d", 12345);
45 ASSERT (result != NULL);
46 ASSERT (strcmp (result, "12345") == 0);
47 ASSERT (length == 5);
48 if (size < 6)
49 ASSERT (result != buf);
50 ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
51 if (result != buf)
52 free (result);
53 }
54 }