Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test case for experimental API remove_matches #114111

Merged
merged 1 commit into from
Jul 31, 2023
Merged

Improve test case for experimental API remove_matches #114111

merged 1 commit into from
Jul 31, 2023

Conversation

allaboutevemirolive
Copy link
Contributor

@allaboutevemirolive allaboutevemirolive commented Jul 26, 2023

Add Test Cases for remove_matches Function

Motivation

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. The remove_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

  1. Single Pattern Occurrence (test_single_pattern_occurrence):

    • Description: Tests the removal of a single pattern occurrence from the text.
    • Input: Text: "abc", Pattern: 'b'
    • Expected Output: "ac"
  2. Repeat Test Single Pattern Occurrence (repeat_test_single_pattern_occurrence):

    • Description: Repeats the previous test case to ensure consecutive removal of the same pattern.
    • Input: Text: "ac", Pattern: 'b'
    • Expected Output: "ac"
  3. Single Character Pattern (test_single_character_pattern):

    • Description: Tests the removal of a single character pattern.
    • Input: Text: "abcb", Pattern: 'b'
    • Expected Output: "ac"
  4. Pattern with Special Characters (test_pattern_with_special_characters):

    • Description: Tests the removal of a pattern containing special characters.
    • Input: Text: "ศไทย中华Việt Nam; foobarศ", Pattern: 'ศ'
    • Expected Output: "ไทย中华Việt Nam; foobar"
  5. Pattern Empty Text and Pattern (test_pattern_empty_text_and_pattern):

    • Description: Tests the removal of an empty pattern from an empty text.
    • Input: Text: "", Pattern: ""
    • Expected Output: ""
  6. Pattern Empty Text (test_pattern_empty_text):

    • Description: Tests the removal of a pattern from an empty text.
    • Input: Text: "", Pattern: "something"
    • Expected Output: ""
  7. Empty Pattern (test_empty_pattern):

    • Description: Tests the behavior of removing an empty pattern from the text.
    • Input: Text: "Testing with empty pattern.", Pattern: ""
    • Expected Output: "Testing with empty pattern."
  8. Multiple Consecutive Patterns 1 (test_multiple_consecutive_patterns_1):

    • Description: Tests the removal of multiple consecutive occurrences of a pattern.
    • Input: Text: "aaaaa", Pattern: 'a'
    • Expected Output: ""
  9. Multiple Consecutive Patterns 2 (test_multiple_consecutive_patterns_2):

    • Description: Tests the removal of a longer pattern that occurs consecutively.
    • Input: Text: "Hello world****today!", Pattern: "**"
    • Expected Output: "Hello worldtoday!"
  10. Case Insensitive Pattern (test_case_insensitive_pattern):

    • Description: Tests the removal of a case-insensitive pattern from the text.
    • Input: Text: "CASE ** SeNsItIvE ** PaTtErN.", Pattern: "sEnSiTiVe"
    • Expected Output: "CASE ** SeNsItIvE ** PaTtErN."

@rustbot
Copy link
Collaborator

rustbot commented Jul 26, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 26, 2023
@Mark-Simulacrum
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 31, 2023

📌 Commit adb36cb has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 31, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#114111 (Improve test case for experimental API remove_matches)
 - rust-lang#114169 (refactor builtin unsize handling, extend comments)
 - rust-lang#114182 (clean up after 113312)
 - rust-lang#114193 (Update lexer emoji diagnostics to Unicode 15.0)
 - rust-lang#114200 (Detect trait upcasting through struct tail unsizing in new solver select)
 - rust-lang#114228 (Check lazy type aliases for well-formedness)
 - rust-lang#114267 (Map RPITIT's opaque type bounds back from projections to opaques)
 - rust-lang#114269 (Migrate GUI colors test to original CSS color format)
 - rust-lang#114286 (Add missing feature gate in multiple_supertrait_upcastable doc)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 31, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#112858 (Update Android system definitions and add riscv-linux-android as tier 3 target)
 - rust-lang#113717 (remove repetitive words)
 - rust-lang#113725 (Move MinGW linker dist option to proper section)
 - rust-lang#113740 (Update `.gitmodules` to use shallow submodule clones)
 - rust-lang#113889 (Fix ice tests when librustc-driver is linked dynamically)
 - rust-lang#113906 (etc: add `RUSTC_BOOTSTRAP` to rust-analyzer config)
 - rust-lang#113920 (fix(resolve): report unresolved imports firstly)
 - rust-lang#114111 (Improve test case for experimental API remove_matches)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e981db0 into rust-lang:master Jul 31, 2023
11 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants