Branch data Line data Source code
1 : : #include "test_libmem_all.h"
2 : :
3 : : /**
4 : : * @brief Capture the m_copy_data divisibility negative case
5 : : *
6 : : * The helper is expected to reject source payloads whose byte size cannot be
7 : : * represented as a whole number of destination elements
8 : : *
9 : : * @return Return describing success or failure
10 : : */
11 : 1 : static Return capture_libmem_core_data_non_divisible_source(void)
12 : : {
13 : 1 : INITTEST;
14 : :
15 : 1 : m_create(unsigned short,destination);
16 : 1 : m_create(unsigned char,source);
17 : :
18 : 1 : const unsigned char odd_source_bytes[] = {
19 : : (unsigned char)'a',
20 : : (unsigned char)'b',
21 : : (unsigned char)'c'
22 : : };
23 : :
24 : 1 : ASSERT(SUCCESS == m_copy_buffer(source,sizeof(odd_source_bytes),odd_source_bytes));
25 : 1 : ASSERT(FAILURE == m_copy_data(destination,source));
26 : 1 : ASSERT(destination->length == 0);
27 : 1 : ASSERT(destination->string_length == 0);
28 : 1 : ASSERT(destination->is_string == false);
29 : :
30 : 1 : call(m_del(destination));
31 : 1 : call(m_del(source));
32 : :
33 : 1 : deliver(status);
34 : : }
35 : :
36 : : /**
37 : : * @brief Check that m_copy_data rejects source byte counts with destination tails
38 : : *
39 : : * @return Return describing success or failure
40 : : */
41 : 1 : Return test_libmem_0060(void)
42 : : {
43 : 1 : INITTEST;
44 : :
45 : : static const char expected_stderr_pattern_libmem_0060[] =
46 : : "\\A.*Source byte count 3 is not divisible by destination element size 2.*\\Z";
47 : :
48 : 1 : ASSERT(SUCCESS == match_function_output(NULL,expected_stderr_pattern_libmem_0060,capture_libmem_core_data_non_divisible_source));
49 : :
50 : 1 : RETURN_STATUS;
51 : : }
|