Branch data Line data Source code
1 : : #include "test_libmem_all.h"
2 : :
3 : : /**
4 : : * @brief Check internal replace mode on multi-byte strings and aliased empty replacement
5 : : *
6 : : * @return Return describing success or failure
7 : : */
8 : 1 : Return test_libmem_0043(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(20),
17 : : UINT32_C(30),
18 : : UINT32_C(40),
19 : : UINT32_C(0)
20 : : };
21 : :
22 : 1 : ASSERT(SUCCESS == m_copy_buffer(code_units,sizeof(initial_code_units),initial_code_units));
23 : 1 : ASSERT(SUCCESS == m_to_string(code_units));
24 : :
25 : 1 : const uint32_t *aliased_suffix = m_data_ro(uint32_t,code_units);
26 : 1 : ASSERT(aliased_suffix != NULL);
27 : :
28 : 1 : IF(aliased_suffix != NULL)
29 : : {
30 : 1 : aliased_suffix += 2;
31 : 1 : ASSERT(SUCCESS == mem_core_string(SOURCE_BOUNDED_STRING | TRANSFER_REPLACE,code_units,code_units->length * sizeof(uint32_t),aliased_suffix));
32 : : }
33 : :
34 : 1 : ASSERT(code_units->length == 3);
35 : 1 : ASSERT(code_units->string_length == 2);
36 : 1 : ASSERT(code_units->is_string == true);
37 : :
38 : 1 : const uint32_t *const_code_unit_view = m_data_ro(uint32_t,code_units);
39 : 1 : ASSERT(const_code_unit_view != NULL);
40 : :
41 : 1 : IF(const_code_unit_view != NULL)
42 : : {
43 : 1 : ASSERT(const_code_unit_view[0] == UINT32_C(30));
44 : 1 : ASSERT(const_code_unit_view[1] == UINT32_C(40));
45 : 1 : ASSERT(const_code_unit_view[2] == UINT32_C(0));
46 : : }
47 : :
48 : 1 : aliased_suffix = m_data_ro(uint32_t,code_units);
49 : 1 : ASSERT(aliased_suffix != NULL);
50 : :
51 : 1 : size_t code_units_length = 0U;
52 : 1 : ASSERT(SUCCESS == m_string_length(code_units,&code_units_length));
53 : :
54 : 1 : IF(aliased_suffix != NULL)
55 : : {
56 : 1 : aliased_suffix += code_units_length;
57 : 1 : ASSERT(SUCCESS == mem_core_string(SOURCE_UNBOUNDED_STRING | TRANSFER_REPLACE,code_units,0,aliased_suffix));
58 : : }
59 : :
60 : 1 : ASSERT(code_units->length == 1);
61 : 1 : ASSERT(code_units->string_length == 0);
62 : 1 : ASSERT(code_units->is_string == true);
63 : :
64 : 1 : const_code_unit_view = m_data_ro(uint32_t,code_units);
65 : 1 : ASSERT(const_code_unit_view != NULL);
66 : :
67 : 1 : IF(const_code_unit_view != NULL)
68 : : {
69 : 1 : ASSERT(const_code_unit_view[0] == UINT32_C(0));
70 : : }
71 : :
72 : 1 : call(m_del(code_units));
73 : :
74 : 1 : RETURN_STATUS;
75 : : }
|