Improve test case for experimental API remove_matches #114111
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Test Cases for
remove_matches
FunctionMotivation
After reading the discussion in this GitHub thread, I'm trying to redesign the current API to use less memory when working with
String
and to make it simpler. I've discovered that some test cases are very helpful in ensuring that the new API behaves as intended. I'm still in the process of redesigning the current API, and these test cases have proven to be very useful.Testing
The current test has been tested with the command
./x test --stage 0 library/alloc
.Overview
This pull request adds several new test cases for the
remove_matches
function to make sure it works correctly in different situations. Theremove_matches
function is used to get rid of all instances of a specific pattern from a given text. These test cases thoroughly check how the function behaves in various scenarios.Test Cases
Single Pattern Occurrence (
test_single_pattern_occurrence
):Repeat Test Single Pattern Occurrence (
repeat_test_single_pattern_occurrence
):Single Character Pattern (
test_single_character_pattern
):Pattern with Special Characters (
test_pattern_with_special_characters
):Pattern Empty Text and Pattern (
test_pattern_empty_text_and_pattern
):Pattern Empty Text (
test_pattern_empty_text
):Empty Pattern (
test_empty_pattern
):Multiple Consecutive Patterns 1 (
test_multiple_consecutive_patterns_1
):Multiple Consecutive Patterns 2 (
test_multiple_consecutive_patterns_2
):Case Insensitive Pattern (
test_case_insensitive_pattern
):