On 25/08/2023 07:49, David Gow wrote:
On Thu, 24 Aug 2023 at 22:33, Richard Fitzgerald
<rf@xxxxxxxxxxxxxxxxxxxxx> wrote:
Replace the minimal tests with more-thorough testing.
string_stream_init_test() tests that struct string_stream is
initialized correctly.
string_stream_line_add_test() adds a series of numbered lines and
checks that the resulting string contains all the lines.
string_stream_variable_length_line_test() adds a large number of
lines of varying length to create many fragments, then tests that all
lines are present.
string_stream_append_test() tests various cases of using
string_stream_append() to append the content of one stream to another.
Adds string_stream_append_empty_string_test() to test that adding an
empty string to a string_stream doesn't create a new empty fragment.
Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
---
Changes since V4:
- Test cases for appending empty strings have been squashed into this
patch.
- Call to string_stream_get_string() is wrapped in a local function
get_concatenated_string(). This is to avoid a lot of code churn later
when string_stream_get_string() is changed to return an unmanaged buffer.
---
This looks good to me. I'm not 100% sold on the
'get_concatenated_string()' function long-term (despite its obvious
benefits during the refactoring), but that's just personal taste. This
version is fine regardless.
Yes, we can remove it later. I just wanted to avoid having one enormous
patch that changes everything all over the place.