Branch data Line data Source code
1 : : #include "test_libtestitall_all.h"
2 : :
3 : : /**
4 : : * @brief Verify direct small-string diff generation through compare_memory_strings
5 : : *
6 : : * This test prepares two short multi-line strings in string-mode memory descriptors
7 : : * and compares them through compare_memory_strings(). The produced unified diff
8 : : * is checked against the exact expected text for this small input pair
9 : : *
10 : : * The test verifies that compare_memory_strings():
11 : : * - accepts byte-sized string descriptors as input
12 : : * - stores the produced diff into the destination memory descriptor
13 : : * - produces the expected compact unified diff for a simple one-line replacement
14 : : *
15 : : * @return Return status code
16 : : */
17 : 1 : Return test_libtestitall_0008(void)
18 : : {
19 : 1 : INITTEST;
20 : :
21 : 1 : const char expected_diff[] = "-line2\n+line3\n";
22 : :
23 : 1 : m_create(char,left_text_buffer,MEMORY_STRING);
24 : 1 : m_create(char,right_text_buffer,MEMORY_STRING);
25 : 1 : m_create(char,actual_diff_buffer,MEMORY_STRING);
26 : :
27 : 1 : ASSERT(SUCCESS == m_copy_literal(left_text_buffer,"line1\nline2\n"));
28 : 1 : ASSERT(SUCCESS == m_copy_literal(right_text_buffer,"line1\nline3\n"));
29 : :
30 : 1 : ASSERT(SUCCESS == compare_memory_strings(
31 : : actual_diff_buffer,
32 : : left_text_buffer,
33 : : right_text_buffer));
34 : :
35 : 1 : ASSERT(0 == strcmp(expected_diff,m_text(actual_diff_buffer)));
36 : :
37 : 1 : m_del(actual_diff_buffer);
38 : 1 : m_del(right_text_buffer);
39 : 1 : m_del(left_text_buffer);
40 : :
41 : 1 : RETURN_STATUS;
42 : : }
|