LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0024.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 % 2 2
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #include "test_libmem_all.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Capture the zero-sized string-length negative case
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : static Return capture_libmem_zero_sized_element_string_length(void)
       9                 :             : {
      10                 :           1 :         INITTEST;
      11                 :             : 
      12                 :           1 :         size_t measured_length = SIZE_MAX;
      13                 :           1 :         unsigned char payload[] = {0U};
      14                 :           1 :         memory invalid_descriptor = m_init(unsigned char,MEMORY_DATA);
      15                 :             : 
      16                 :             :         /* Keep the backing storage valid so this test reaches only the
      17                 :             :            deliberately invalid zero-sized element condition */
      18                 :           1 :         invalid_descriptor.data = payload;
      19                 :           1 :         invalid_descriptor.actually_allocated_bytes = sizeof(payload);
      20                 :           1 :         invalid_descriptor.length = 1;
      21                 :           1 :         invalid_descriptor.single_element_size = 0;
      22                 :             : 
      23                 :           1 :         ASSERT(FAILURE == m_string_length(&invalid_descriptor,&measured_length));
      24                 :           1 :         ASSERT(measured_length == SIZE_MAX);
      25                 :             : 
      26                 :           1 :         deliver(status);
      27                 :             : }
      28                 :             : 
      29                 :             : /**
      30                 :             :  * @brief Check string_length rejects zero-sized elements
      31                 :             :  *
      32                 :             :  * @return Return describing success or failure
      33                 :             :  */
      34                 :           1 : Return test_libmem_0024(void)
      35                 :             : {
      36                 :           1 :         INITTEST;
      37                 :             : 
      38                 :             :         static const char expected_stderr_pattern_libmem_0024[] =
      39                 :             :                 "\\A.*Descriptor element size is zero \\(uninitialized\\).*\\Z";
      40                 :             : 
      41                 :           1 :         ASSERT(SUCCESS == match_function_output(NULL,expected_stderr_pattern_libmem_0024,capture_libmem_zero_sized_element_string_length));
      42                 :             : 
      43                 :           1 :         RETURN_STATUS;
      44                 :             : }
        

Generated by: LCOV version 2.0-1