LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0050.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 16 16
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 m_finalize_string with the default flag after a complete direct write
       5                 :             :  *
       6                 :             :  * Reserves a string buffer, writes a complete zero-terminated text value through
       7                 :             :  * m_data(...), and finalizes the visible length without forcing a replacement
       8                 :             :  * terminator. The assertions verify that the already present terminator is
       9                 :             :  * accepted and the descriptor exposes the written text as a valid string
      10                 :             :  *
      11                 :             :  * @return Return describing success or failure
      12                 :             :  */
      13                 :           1 : Return test_libmem_0050(void)
      14                 :             : {
      15                 :           1 :         INITTEST;
      16                 :             : 
      17                 :           1 :         m_create(char,title,MEMORY_STRING);
      18                 :             : 
      19                 :           1 :         const char draft[] = "draft";
      20                 :             : 
      21                 :           1 :         ASSERT(SUCCESS == m_resize(title,sizeof(draft)));
      22                 :             : 
      23                 :           1 :         char *title_view = m_data(char,title);
      24                 :           1 :         ASSERT(title_view != NULL);
      25                 :             : 
      26                 :           1 :         IF(title_view != NULL)
      27                 :             :         {
      28                 :           1 :                 memcpy(title_view,draft,sizeof(draft));
      29                 :             :         }
      30                 :             : 
      31                 :           1 :         ASSERT(SUCCESS == m_finalize_string(title,sizeof(draft) - 1U));
      32                 :           1 :         ASSERT(title->length == sizeof(draft));
      33                 :           1 :         ASSERT(title->string_length == strlen("draft"));
      34                 :           1 :         ASSERT(title->is_string == true);
      35                 :           1 :         ASSERT(0 == strcmp(m_text(title),"draft"));
      36                 :           1 :         call(m_del(title));
      37                 :             : 
      38                 :           1 :         RETURN_STATUS;
      39                 :             : }
        

Generated by: LCOV version 2.0-1