LCOV - code coverage report
Current view: top level - libs/mem/tests/src - test_libmem_0059.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 62 62
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 raw data append and copy wrappers on ordinary and aliased payloads
       5                 :             :  *
       6                 :             :  * @return Return describing success or failure
       7                 :             :  */
       8                 :           1 : Return test_libmem_0059(void)
       9                 :             : {
      10                 :           1 :         INITTEST;
      11                 :             : 
      12                 :           1 :         m_create(unsigned short,destination_words);
      13                 :           1 :         m_create(unsigned char,source_bytes);
      14                 :             : 
      15                 :           1 :         const unsigned char external_prefix[] = {
      16                 :             :                 (unsigned char)'A',
      17                 :             :                 (unsigned char)'B',
      18                 :             :                 (unsigned char)'C',
      19                 :             :                 (unsigned char)'D'
      20                 :             :         };
      21                 :           1 :         const unsigned char external_suffix[] = {
      22                 :             :                 (unsigned char)'E',
      23                 :             :                 (unsigned char)'F'
      24                 :             :         };
      25                 :           1 :         const unsigned char aliased_append_seed[] = {
      26                 :             :                 (unsigned char)'1',
      27                 :             :                 (unsigned char)'2',
      28                 :             :                 (unsigned char)'3',
      29                 :             :                 (unsigned char)'4'
      30                 :             :         };
      31                 :           1 :         const unsigned char aliased_replace_seed[] = {
      32                 :             :                 (unsigned char)'a',
      33                 :             :                 (unsigned char)'b',
      34                 :             :                 (unsigned char)'c',
      35                 :             :                 (unsigned char)'d',
      36                 :             :                 (unsigned char)'e',
      37                 :             :                 (unsigned char)'f'
      38                 :             :         };
      39                 :             : 
      40                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(destination_words,sizeof(external_prefix),external_prefix));
      41                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(source_bytes,sizeof(external_suffix),external_suffix));
      42                 :           1 :         ASSERT(SUCCESS == m_concat_data(destination_words,source_bytes));
      43                 :             : 
      44                 :           1 :         ASSERT(destination_words->length == 3);
      45                 :           1 :         ASSERT(destination_words->string_length == 0);
      46                 :           1 :         ASSERT(destination_words->is_string == false);
      47                 :             : 
      48                 :           1 :         const unsigned char *destination_view = (const unsigned char *)m_raw_data_ro(destination_words);
      49                 :           1 :         ASSERT(destination_view != NULL);
      50                 :             : 
      51                 :           1 :         IF(destination_view != NULL)
      52                 :             :         {
      53                 :           1 :                 ASSERT(destination_view[0] == (unsigned char)'A');
      54                 :           1 :                 ASSERT(destination_view[1] == (unsigned char)'B');
      55                 :           1 :                 ASSERT(destination_view[2] == (unsigned char)'C');
      56                 :           1 :                 ASSERT(destination_view[3] == (unsigned char)'D');
      57                 :           1 :                 ASSERT(destination_view[4] == (unsigned char)'E');
      58                 :           1 :                 ASSERT(destination_view[5] == (unsigned char)'F');
      59                 :             :         }
      60                 :             : 
      61                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(destination_words,sizeof(aliased_append_seed),aliased_append_seed));
      62                 :             : 
      63                 :           1 :         memory aliased_append_source = m_init(unsigned char,MEMORY_DATA);
      64                 :           1 :         unsigned char *destination_data = (unsigned char *)m_raw_data(destination_words);
      65                 :           1 :         ASSERT(destination_data != NULL);
      66                 :             : 
      67                 :           1 :         IF(destination_data != NULL)
      68                 :             :         {
      69                 :           1 :                 aliased_append_source.data = destination_data + 1;
      70                 :             :         }
      71                 :             : 
      72                 :           1 :         aliased_append_source.length = 2;
      73                 :             : 
      74                 :           1 :         ASSERT(SUCCESS == m_concat_data(destination_words,&aliased_append_source));
      75                 :           1 :         ASSERT(destination_words->length == 3);
      76                 :             : 
      77                 :           1 :         destination_view = (const unsigned char *)m_raw_data_ro(destination_words);
      78                 :           1 :         ASSERT(destination_view != NULL);
      79                 :             : 
      80                 :           1 :         IF(destination_view != NULL)
      81                 :             :         {
      82                 :           1 :                 ASSERT(destination_view[0] == (unsigned char)'1');
      83                 :           1 :                 ASSERT(destination_view[1] == (unsigned char)'2');
      84                 :           1 :                 ASSERT(destination_view[2] == (unsigned char)'3');
      85                 :           1 :                 ASSERT(destination_view[3] == (unsigned char)'4');
      86                 :           1 :                 ASSERT(destination_view[4] == (unsigned char)'2');
      87                 :           1 :                 ASSERT(destination_view[5] == (unsigned char)'3');
      88                 :             :         }
      89                 :             : 
      90                 :           1 :         ASSERT(SUCCESS == m_copy_buffer(destination_words,sizeof(aliased_replace_seed),aliased_replace_seed));
      91                 :             : 
      92                 :           1 :         memory aliased_replace_source = m_init(unsigned char,MEMORY_DATA);
      93                 :           1 :         destination_data = (unsigned char *)m_raw_data(destination_words);
      94                 :           1 :         ASSERT(destination_data != NULL);
      95                 :             : 
      96                 :           1 :         IF(destination_data != NULL)
      97                 :             :         {
      98                 :           1 :                 aliased_replace_source.data = destination_data + 1;
      99                 :             :         }
     100                 :             : 
     101                 :           1 :         aliased_replace_source.length = 4;
     102                 :             : 
     103                 :           1 :         ASSERT(SUCCESS == m_copy_data(destination_words,&aliased_replace_source));
     104                 :           1 :         ASSERT(destination_words->length == 2);
     105                 :           1 :         ASSERT(destination_words->string_length == 0);
     106                 :           1 :         ASSERT(destination_words->is_string == false);
     107                 :             : 
     108                 :           1 :         destination_view = (const unsigned char *)m_raw_data_ro(destination_words);
     109                 :           1 :         ASSERT(destination_view != NULL);
     110                 :             : 
     111                 :           1 :         IF(destination_view != NULL)
     112                 :             :         {
     113                 :           1 :                 ASSERT(destination_view[0] == (unsigned char)'b');
     114                 :           1 :                 ASSERT(destination_view[1] == (unsigned char)'c');
     115                 :           1 :                 ASSERT(destination_view[2] == (unsigned char)'d');
     116                 :           1 :                 ASSERT(destination_view[3] == (unsigned char)'e');
     117                 :             :         }
     118                 :             : 
     119                 :           1 :         call(m_del(source_bytes));
     120                 :           1 :         call(m_del(destination_words));
     121                 :             : 
     122                 :           1 :         RETURN_STATUS;
     123                 :             : }
        

Generated by: LCOV version 2.0-1