Skip to content

Commit

Permalink
Add tests for Pattern for &[char]
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Jun 16, 2021
1 parent 5c1dc1f commit 2ca3fb0
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ pub fn execute_strings_split() {
let parallel: Vec<_> = string.par_split(separator).collect();
assert_eq!(serial, parallel);

let pattern: &[char] = &['\u{0}', separator, '\u{1F980}'];
let serial: Vec<_> = string.split(pattern).collect();
let parallel: Vec<_> = string.par_split(pattern).collect();
assert_eq!(serial, parallel);

let serial_fn: Vec<_> = string.split(|c| c == separator).collect();
let parallel_fn: Vec<_> = string.par_split(|c| c == separator).collect();
assert_eq!(serial_fn, parallel_fn);
Expand All @@ -73,9 +78,12 @@ pub fn execute_strings_split() {
let serial: Vec<_> = string.split_terminator(separator).collect();
let parallel: Vec<_> = string.par_split_terminator(separator).collect();
assert_eq!(serial, parallel);
}

for &(string, separator) in &tests {
let pattern: &[char] = &['\u{0}', separator, '\u{1F980}'];
let serial: Vec<_> = string.split_terminator(pattern).collect();
let parallel: Vec<_> = string.par_split_terminator(pattern).collect();
assert_eq!(serial, parallel);

let serial: Vec<_> = string.split_terminator(|c| c == separator).collect();
let parallel: Vec<_> = string.par_split_terminator(|c| c == separator).collect();
assert_eq!(serial, parallel);
Expand All @@ -99,6 +107,11 @@ pub fn execute_strings_split() {
let parallel: Vec<_> = string.par_matches(separator).collect();
assert_eq!(serial, parallel);

let pattern: &[char] = &['\u{0}', separator, '\u{1F980}'];
let serial: Vec<_> = string.matches(pattern).collect();
let parallel: Vec<_> = string.par_matches(pattern).collect();
assert_eq!(serial, parallel);

let serial_fn: Vec<_> = string.matches(|c| c == separator).collect();
let parallel_fn: Vec<_> = string.par_matches(|c| c == separator).collect();
assert_eq!(serial_fn, parallel_fn);
Expand All @@ -109,6 +122,11 @@ pub fn execute_strings_split() {
let parallel: Vec<_> = string.par_match_indices(separator).collect();
assert_eq!(serial, parallel);

let pattern: &[char] = &['\u{0}', separator, '\u{1F980}'];
let serial: Vec<_> = string.match_indices(pattern).collect();
let parallel: Vec<_> = string.par_match_indices(pattern).collect();
assert_eq!(serial, parallel);

let serial_fn: Vec<_> = string.match_indices(|c| c == separator).collect();
let parallel_fn: Vec<_> = string.par_match_indices(|c| c == separator).collect();
assert_eq!(serial_fn, parallel_fn);
Expand Down

0 comments on commit 2ca3fb0

Please sign in to comment.