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 (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ...))
21 {
22 uint8_t buf[8];
23 int size;
24
25
26
27 for (size = 0; size <= 8; size++)
28 {
29 size_t length = size;
30 uint8_t *result = my_asnprintf (NULL, &length, "%d", 12345);
31 static const uint8_t expected[] = "12345";
32 ASSERT (result != NULL);
33 ASSERT (u8_strcmp (result, expected) == 0);
34 ASSERT (length == 5);
35 free (result);
36 }
37
38 for (size = 0; size <= 8; size++)
39 {
40 static const uint8_t initializer[] = "DEADBEEF";
41 static const uint8_t expected[] = "12345";
42 size_t length;
43 uint8_t *result;
44
45 u8_cpy (buf, initializer, 8);
46 length = size;
47 result = my_asnprintf (buf, &length, "%d", 12345);
48 ASSERT (result != NULL);
49 ASSERT (u8_strcmp (result, expected) == 0);
50 ASSERT (length == 5);
51 if (size < 6)
52 ASSERT (result != buf);
53 ASSERT (u8_cmp (buf + size, initializer + size, 8 - size) == 0);
54 if (result != buf)
55 free (result);
56 }
57 }