LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0027.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 49 49
Test Date: 2026-07-12 01:01:34 Functions: 100.0 % 1 1
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #include "test_libmem_all.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Check bounded string concat on multi-byte buffers and softly clamped self-aliasing
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : Return test_libmem_0027(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(0x00010000),
      16                 :             :                 UINT32_C(0x00000001),
      17                 :             :                 UINT32_C(0x00000000)
      18                 :             :         };
      19                 :           1 :         const uint32_t bounded_suffix[] = {
      20                 :             :                 UINT32_C(0x01000000),
      21                 :             :                 UINT32_C(0x00000002),
      22                 :             :                 UINT32_C(0x00000000),
      23                 :             :                 UINT32_C(0x00000009)
      24                 :             :         };
      25                 :             : 
      26                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(code_units,sizeof(initial_code_units),initial_code_units));
      27                 :           1 :         ASSERT(SUCCESS == m_to_string(code_units));
      28                 :           1 :         ASSERT(SUCCESS == m_concat_string(code_units,sizeof(bounded_suffix),bounded_suffix));
      29                 :           1 :         ASSERT(code_units->length == 5);
      30                 :           1 :         ASSERT(code_units->string_length == 4);
      31                 :           1 :         ASSERT(code_units->is_string == true);
      32                 :             : 
      33                 :           1 :         const uint32_t *const_code_unit_view = m_data_ro(uint32_t,code_units);
      34                 :           1 :         ASSERT(const_code_unit_view != NULL);
      35                 :             : 
      36                 :           1 :         IF(const_code_unit_view != NULL)
      37                 :             :         {
      38                 :           1 :                 ASSERT(const_code_unit_view[0] == UINT32_C(0x00010000));
      39                 :           1 :                 ASSERT(const_code_unit_view[1] == UINT32_C(0x00000001));
      40                 :           1 :                 ASSERT(const_code_unit_view[2] == UINT32_C(0x01000000));
      41                 :           1 :                 ASSERT(const_code_unit_view[3] == UINT32_C(0x00000002));
      42                 :           1 :                 ASSERT(const_code_unit_view[4] == UINT32_C(0x00000000));
      43                 :             :         }
      44                 :             : 
      45                 :           1 :         const uint32_t *aliased_suffix = m_data_ro(uint32_t,code_units);
      46                 :           1 :         ASSERT(aliased_suffix != NULL);
      47                 :             : 
      48                 :           1 :         IF(aliased_suffix != NULL)
      49                 :             :         {
      50                 :           1 :                 aliased_suffix += 2;
      51                 :           1 :                 ASSERT(SUCCESS == m_concat_string(code_units,code_units->length * sizeof(uint32_t),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_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(0x00010000));
      64                 :           1 :                 ASSERT(const_code_unit_view[1] == UINT32_C(0x00000001));
      65                 :           1 :                 ASSERT(const_code_unit_view[2] == UINT32_C(0x01000000));
      66                 :           1 :                 ASSERT(const_code_unit_view[3] == UINT32_C(0x00000002));
      67                 :           1 :                 ASSERT(const_code_unit_view[4] == UINT32_C(0x01000000));
      68                 :           1 :                 ASSERT(const_code_unit_view[5] == UINT32_C(0x00000002));
      69                 :           1 :                 ASSERT(const_code_unit_view[6] == UINT32_C(0x00000000));
      70                 :             :         }
      71                 :             : 
      72                 :           1 :         aliased_suffix = m_data_ro(uint32_t,code_units);
      73                 :           1 :         ASSERT(aliased_suffix != NULL);
      74                 :             : 
      75                 :           1 :         size_t code_units_length = 0U;
      76                 :           1 :         ASSERT(SUCCESS == m_string_length(code_units,&code_units_length));
      77                 :             : 
      78                 :           1 :         IF(aliased_suffix != NULL)
      79                 :             :         {
      80                 :           1 :                 aliased_suffix += code_units_length;
      81                 :           1 :                 ASSERT(SUCCESS == m_concat_string(code_units,sizeof(uint32_t),aliased_suffix));
      82                 :             :         }
      83                 :             : 
      84                 :           1 :         ASSERT(code_units->length == 7);
      85                 :           1 :         ASSERT(code_units->string_length == 6);
      86                 :           1 :         ASSERT(code_units->is_string == true);
      87                 :             : 
      88                 :           1 :         call(m_del(code_units));
      89                 :             : 
      90                 :           1 :         RETURN_STATUS;
      91                 :             : }
        

Generated by: LCOV version 2.0-1