LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0044.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 33 33
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 fixed-string append and literal append sugar on byte and multi-byte string descriptors
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : Return test_libmem_0044(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 suffix[] = {'-','l','i','t','\0'};
      18                 :             :         static const char empty_suffix[] = "";
      19                 :           1 :         const uint32_t initial_code_units[] = {
      20                 :             :                 UINT32_C(10),
      21                 :             :                 UINT32_C(0)
      22                 :             :         };
      23                 :           1 :         const uint32_t literal_suffix[] = {
      24                 :             :                 UINT32_C(20),
      25                 :             :                 UINT32_C(30),
      26                 :             :                 UINT32_C(0)
      27                 :             :         };
      28                 :             : 
      29                 :           1 :         ASSERT(SUCCESS == m_copy_fixed_string(string_buffer,sizeof(base_text),base_text));
      30                 :           1 :         ASSERT(SUCCESS == m_concat_fixed_string(string_buffer,sizeof(suffix),suffix));
      31                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base-lit"));
      32                 :           1 :         ASSERT(SUCCESS == m_concat_literal(string_buffer,"!"));
      33                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base-lit!"));
      34                 :           1 :         ASSERT(SUCCESS == m_concat_fixed_string(string_buffer,sizeof(empty_suffix),empty_suffix));
      35                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base-lit!"));
      36                 :           1 :         ASSERT(string_buffer->string_length == strlen("base-lit!"));
      37                 :           1 :         ASSERT(string_buffer->is_string == true);
      38                 :             : 
      39                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(code_units,sizeof(initial_code_units),initial_code_units));
      40                 :           1 :         ASSERT(SUCCESS == m_to_string(code_units));
      41                 :           1 :         ASSERT(SUCCESS == m_concat_fixed_string(code_units,sizeof(literal_suffix),literal_suffix));
      42                 :           1 :         ASSERT(code_units->length == 4);
      43                 :           1 :         ASSERT(code_units->string_length == 3);
      44                 :           1 :         ASSERT(code_units->is_string == true);
      45                 :             : 
      46                 :           1 :         const uint32_t *code_unit_view = m_data_ro(uint32_t,code_units);
      47                 :           1 :         ASSERT(code_unit_view != NULL);
      48                 :             : 
      49                 :           1 :         IF(code_unit_view != NULL)
      50                 :             :         {
      51                 :           1 :                 ASSERT(code_unit_view[0] == UINT32_C(10));
      52                 :           1 :                 ASSERT(code_unit_view[1] == UINT32_C(20));
      53                 :           1 :                 ASSERT(code_unit_view[2] == UINT32_C(30));
      54                 :           1 :                 ASSERT(code_unit_view[3] == UINT32_C(0));
      55                 :             :         }
      56                 :             : 
      57                 :           1 :         call(m_del(code_units));
      58                 :           1 :         call(m_del(string_buffer));
      59                 :             : 
      60                 :           1 :         RETURN_STATUS;
      61                 :             : }
        

Generated by: LCOV version 2.0-1