mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 21:42:44 +00:00
add test for issue 104726
This commit is contained in:
parent
66ccf36f16
commit
d576a9b241
@ -1631,6 +1631,18 @@ fn strslice_issue_16878() {
|
|||||||
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
|
assert!(!"00abc01234567890123456789abc".contains("bcabc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn strslice_issue_104726() {
|
||||||
|
// Edge-case in the simd_contains impl.
|
||||||
|
// The first and last byte are the same so it backtracks by one byte
|
||||||
|
// which aligns with the end of the string. Previously incorrect offset calculations
|
||||||
|
// lead to out-of-bounds slicing.
|
||||||
|
#[rustfmt::skip]
|
||||||
|
let needle = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaba";
|
||||||
|
let haystack = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab";
|
||||||
|
assert!(!haystack.contains(needle));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(miri, ignore)] // Miri is too slow
|
#[cfg_attr(miri, ignore)] // Miri is too slow
|
||||||
fn test_strslice_contains() {
|
fn test_strslice_contains() {
|
||||||
|
Loading…
Reference in New Issue
Block a user