Branch data Line data Source code
1 : : #include "test_libmem_all.h"
2 : :
3 : : /**
4 : : * @brief Check the public unbounded wrapper on multi-byte strings and internal sources
5 : : *
6 : : * @return Return describing success or failure
7 : : */
8 : 1 : Return test_libmem_0031(void)
9 : : {
10 : 1 : INITTEST;
11 : :
12 : 1 : m_create(uint32_t,code_units);
13 : :
14 : 1 : const uint32_t initial_code_units[] = {
15 : : UINT32_C(10),
16 : : UINT32_C(0)
17 : : };
18 : 1 : const uint32_t unbounded_suffix[] = {
19 : : UINT32_C(20),
20 : : UINT32_C(30),
21 : : UINT32_C(0)
22 : : };
23 : 1 : const uint32_t literal_suffix[] = {
24 : : UINT32_C(40),
25 : : UINT32_C(0)
26 : : };
27 : :
28 : 1 : ASSERT(SUCCESS == m_copy_buffer(code_units,sizeof(initial_code_units),initial_code_units));
29 : 1 : ASSERT(SUCCESS == m_to_string(code_units));
30 : 1 : ASSERT(SUCCESS == m_concat_string(code_units,unbounded_suffix));
31 : 1 : ASSERT(SUCCESS == mem_core_string(SOURCE_FIXED_STRING | TRANSFER_APPEND,code_units,sizeof(literal_suffix),literal_suffix));
32 : :
33 : 1 : const uint32_t *aliased_suffix = m_data_ro(uint32_t,code_units);
34 : 1 : ASSERT(aliased_suffix != NULL);
35 : :
36 : 1 : IF(aliased_suffix != NULL)
37 : : {
38 : 1 : aliased_suffix += 2;
39 : 1 : ASSERT(SUCCESS == m_concat_string(code_units,aliased_suffix));
40 : : }
41 : :
42 : 1 : aliased_suffix = m_data_ro(uint32_t,code_units);
43 : 1 : ASSERT(aliased_suffix != NULL);
44 : :
45 : 1 : size_t code_units_length = 0U;
46 : 1 : ASSERT(SUCCESS == m_string_length(code_units,&code_units_length));
47 : :
48 : 1 : IF(aliased_suffix != NULL)
49 : : {
50 : 1 : aliased_suffix += code_units_length;
51 : 1 : ASSERT(SUCCESS == m_concat_string(code_units,aliased_suffix));
52 : : }
53 : :
54 : 1 : ASSERT(code_units->length == 7);
55 : 1 : ASSERT(code_units->string_length == 6);
56 : 1 : ASSERT(code_units->is_string == true);
57 : :
58 : 1 : const uint32_t *const_code_unit_view = m_data_ro(uint32_t,code_units);
59 : 1 : ASSERT(const_code_unit_view != NULL);
60 : :
61 : 1 : IF(const_code_unit_view != NULL)
62 : : {
63 : 1 : ASSERT(const_code_unit_view[0] == UINT32_C(10));
64 : 1 : ASSERT(const_code_unit_view[1] == UINT32_C(20));
65 : 1 : ASSERT(const_code_unit_view[2] == UINT32_C(30));
66 : 1 : ASSERT(const_code_unit_view[3] == UINT32_C(40));
67 : 1 : ASSERT(const_code_unit_view[4] == UINT32_C(30));
68 : 1 : ASSERT(const_code_unit_view[5] == UINT32_C(40));
69 : 1 : ASSERT(const_code_unit_view[6] == UINT32_C(0));
70 : : }
71 : :
72 : 1 : call(m_del(code_units));
73 : :
74 : 1 : RETURN_STATUS;
75 : : }
|