LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0039.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 20 20
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 negative data-to-string conversion case for stale data-mode string metadata
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : static Return capture_libmem_inconsistent_data_to_string_cache(void)
       9                 :             : {
      10                 :           1 :         INITTEST;
      11                 :             : 
      12                 :           1 :         unsigned char materialized_bytes[] = {'a','b','c','\0'};
      13                 :           1 :         memory invalid_data_descriptor = m_init(unsigned char,MEMORY_DATA);
      14                 :             : 
      15                 :           1 :         invalid_data_descriptor.data = materialized_bytes;
      16                 :           1 :         invalid_data_descriptor.length = sizeof(materialized_bytes);
      17                 :           1 :         invalid_data_descriptor.actually_allocated_bytes = sizeof(materialized_bytes);
      18                 :           1 :         invalid_data_descriptor.string_length = 2;
      19                 :           1 :         invalid_data_descriptor.is_string = false;
      20                 :             : 
      21                 :           1 :         ASSERT(FAILURE == m_to_string(&invalid_data_descriptor));
      22                 :           1 :         ASSERT(invalid_data_descriptor.data == materialized_bytes);
      23                 :           1 :         ASSERT(invalid_data_descriptor.length == sizeof(materialized_bytes));
      24                 :           1 :         ASSERT(invalid_data_descriptor.actually_allocated_bytes == sizeof(materialized_bytes));
      25                 :           1 :         ASSERT(invalid_data_descriptor.string_length == 2);
      26                 :           1 :         ASSERT(invalid_data_descriptor.is_string == false);
      27                 :             : 
      28                 :           1 :         deliver(status);
      29                 :             : }
      30                 :             : 
      31                 :             : /**
      32                 :             :  * @brief Check data-to-string conversion rejection for stale string metadata in data mode
      33                 :             :  *
      34                 :             :  * @return Return describing success or failure
      35                 :             :  */
      36                 :           1 : Return test_libmem_0039(void)
      37                 :             : {
      38                 :           1 :         INITTEST;
      39                 :             : 
      40                 :             :         static const char expected_stderr_pattern_libmem_0039[] =
      41                 :             :                 "\\A.*Data descriptor has non-zero string_length during string conversion.*\\Z";
      42                 :             : 
      43                 :           1 :         ASSERT(SUCCESS == match_function_output(NULL,expected_stderr_pattern_libmem_0039,capture_libmem_inconsistent_data_to_string_cache));
      44                 :             : 
      45                 :           1 :         RETURN_STATUS;
      46                 :             : }
        

Generated by: LCOV version 2.0-1