LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0030.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 23 23
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 public wrappers and fixed-string mode on byte-sized strings
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : Return test_libmem_0030(void)
       9                 :             : {
      10                 :           1 :         INITTEST;
      11                 :             : 
      12                 :             :         static const char base_text[] = "base";
      13                 :           1 :         m_create(char,string_buffer);
      14                 :             : 
      15                 :             :         static const char empty_suffix[] = "";
      16                 :           1 :         const char bounded_suffix[] = {'-','b','\0','x'};
      17                 :             :         static const char unbounded_suffix[] = "-u";
      18                 :           1 :         const char literal_suffix[] = {'-','l','i','t','\0'};
      19                 :             :         static const char expected[] = "base-b-u-lit";
      20                 :             : 
      21                 :           1 :         ASSERT(SUCCESS == m_to_string(string_buffer));
      22                 :           1 :         ASSERT(SUCCESS == m_copy_fixed_string(string_buffer,sizeof(base_text),base_text));
      23                 :           1 :         ASSERT(SUCCESS == m_concat_string(string_buffer,sizeof(empty_suffix),empty_suffix));
      24                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base"));
      25                 :           1 :         ASSERT(string_buffer->string_length == strlen("base"));
      26                 :           1 :         ASSERT(string_buffer->is_string == true);
      27                 :           1 :         ASSERT(SUCCESS == m_concat_string(string_buffer,0,bounded_suffix));
      28                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base"));
      29                 :           1 :         ASSERT(SUCCESS == mem_core_string(SOURCE_FIXED_STRING | TRANSFER_APPEND,string_buffer,0,literal_suffix));
      30                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),"base"));
      31                 :           1 :         ASSERT(SUCCESS == mem_core_string(SOURCE_BOUNDED_STRING | TRANSFER_APPEND,string_buffer,sizeof(bounded_suffix),bounded_suffix));
      32                 :           1 :         ASSERT(SUCCESS == m_concat_string(string_buffer,unbounded_suffix));
      33                 :           1 :         ASSERT(SUCCESS == mem_core_string(SOURCE_FIXED_STRING | TRANSFER_APPEND,string_buffer,sizeof(literal_suffix),literal_suffix));
      34                 :           1 :         ASSERT(string_buffer->is_string == true);
      35                 :           1 :         ASSERT(string_buffer->string_length == sizeof(expected) - 1);
      36                 :           1 :         ASSERT(0 == strcmp(m_text(string_buffer),expected));
      37                 :             : 
      38                 :           1 :         call(m_del(string_buffer));
      39                 :             : 
      40                 :           1 :         RETURN_STATUS;
      41                 :             : }
        

Generated by: LCOV version 2.0-1