Branch data Line data Source code
1 : : #include "test_libmem_all.h"
2 : :
3 : : /**
4 : : * @brief Capture the internal bounded-source negative case past the visible terminator
5 : : *
6 : : * @return Return describing success or failure
7 : : */
8 : 1 : static Return capture_libmem_invalid_internal_bounded_source(void)
9 : : {
10 : 1 : INITTEST;
11 : :
12 : : static const char base_text[] = "base";
13 : :
14 : 1 : m_create(char,string_buffer);
15 : 1 : ASSERT(SUCCESS == m_to_string(string_buffer));
16 : :
17 : 1 : ASSERT(SUCCESS == m_copy_fixed_string(string_buffer,sizeof(base_text),base_text));
18 : 1 : ASSERT(SUCCESS == m_resize(string_buffer,string_buffer->length + 2,ZERO_NEW_MEMORY));
19 : :
20 : 1 : size_t string_buffer_length = 0U;
21 : 1 : ASSERT(SUCCESS == m_string_length(string_buffer,&string_buffer_length));
22 : :
23 : 1 : const char *invalid_internal_source = m_text(string_buffer) + string_buffer_length + 1;
24 : :
25 : 1 : ASSERT(invalid_internal_source != NULL);
26 : :
27 : 1 : IF(invalid_internal_source != NULL)
28 : : {
29 : 1 : ASSERT(FAILURE == m_concat_string(string_buffer,1,invalid_internal_source));
30 : : }
31 : :
32 : 1 : call(m_del(string_buffer));
33 : :
34 : 1 : deliver(status);
35 : : }
36 : :
37 : : /**
38 : : * @brief Check internal bounded mode still rejects starts past the visible terminator
39 : : *
40 : : * @return Return describing success or failure
41 : : */
42 : 1 : Return test_libmem_0035(void)
43 : : {
44 : 1 : INITTEST;
45 : :
46 : : static const char expected_stderr_pattern_libmem_0035[] =
47 : : "\\A.*Source start exceeds destination visible string bounds.*\\Z";
48 : :
49 : 1 : ASSERT(SUCCESS == match_function_output(NULL,expected_stderr_pattern_libmem_0035,capture_libmem_invalid_internal_bounded_source));
50 : :
51 : 1 : RETURN_STATUS;
52 : : }
|