LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0045.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 30 30
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 the overloaded m_concat_string macro for bounded and unbounded calls
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : Return test_libmem_0045(void)
       9                 :             : {
      10                 :           1 :         INITTEST;
      11                 :             : 
      12                 :             :         static const char base_text[] = "base";
      13                 :           1 :         m_create(char,string_buffer);
      14                 :           1 :         ASSERT(SUCCESS == m_to_string(string_buffer));
      15                 :           1 :         m_create(uint32_t,code_units);
      16                 :             : 
      17                 :           1 :         const char unbounded_suffix[] = "-u";
      18                 :           1 :         const char bounded_suffix[] = {'-','b','\0','x'};
      19                 :           1 :         const uint32_t initial_code_units[] = {
      20                 :             :                 UINT32_C(10),
      21                 :             :                 UINT32_C(0)
      22                 :             :         };
      23                 :           1 :         const uint32_t bounded_wide_suffix[] = {
      24                 :             :                 UINT32_C(20),
      25                 :             :                 UINT32_C(0),
      26                 :             :                 UINT32_C(777)
      27                 :             :         };
      28                 :             : 
      29                 :           1 :         ASSERT(SUCCESS == m_copy_fixed_string(string_buffer,sizeof(base_text),base_text));
      30                 :           1 :         ASSERT(SUCCESS == m_concat_string(string_buffer,unbounded_suffix));
      31                 :           1 :         ASSERT(SUCCESS == m_concat_string(string_buffer,sizeof(bounded_suffix),bounded_suffix));
      32                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base-u-b"));
      33                 :           1 :         ASSERT(string_buffer->string_length == strlen("base-u-b"));
      34                 :           1 :         ASSERT(string_buffer->is_string == true);
      35                 :             : 
      36                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(code_units,sizeof(initial_code_units),initial_code_units));
      37                 :           1 :         ASSERT(SUCCESS == m_to_string(code_units));
      38                 :           1 :         ASSERT(SUCCESS == m_concat_string(code_units,sizeof(bounded_wide_suffix),bounded_wide_suffix));
      39                 :           1 :         ASSERT(code_units->length == 3);
      40                 :           1 :         ASSERT(code_units->string_length == 2);
      41                 :           1 :         ASSERT(code_units->is_string == true);
      42                 :             : 
      43                 :           1 :         const uint32_t *code_unit_view = m_data_ro(uint32_t,code_units);
      44                 :           1 :         ASSERT(code_unit_view != NULL);
      45                 :             : 
      46                 :           1 :         IF(code_unit_view != NULL)
      47                 :             :         {
      48                 :           1 :                 ASSERT(code_unit_view[0] == UINT32_C(10));
      49                 :           1 :                 ASSERT(code_unit_view[1] == UINT32_C(20));
      50                 :           1 :                 ASSERT(code_unit_view[2] == UINT32_C(0));
      51                 :             :         }
      52                 :             : 
      53                 :           1 :         call(m_del(code_units));
      54                 :           1 :         call(m_del(string_buffer));
      55                 :             : 
      56                 :           1 :         RETURN_STATUS;
      57                 :             : }
        

Generated by: LCOV version 2.0-1