diff options
| author | Michael Lamparski <diagonaldevice@gmail.com> | 2018-04-16 16:34:09 -0400 |
|---|---|---|
| committer | Michael Lamparski <diagonaldevice@gmail.com> | 2018-04-17 21:31:35 -0400 |
| commit | b74d6922ff15d9f3bf39d317ccd7141518f4f5ec (patch) | |
| tree | 70be92ac0bfff57432121221c5f1a6618de2aa44 /src/liballoc | |
| parent | 9a59133c09980122ce026d20e7832d63b106a927 (diff) | |
| download | rust-b74d6922ff15d9f3bf39d317ccd7141518f4f5ec.tar.gz rust-b74d6922ff15d9f3bf39d317ccd7141518f4f5ec.zip | |
smaller PR just to fix #50002
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/tests/str.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index a3f4c385fe2..e3f198f7362 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -402,6 +402,22 @@ fn test_str_get_maxinclusive() { } #[test] +fn test_str_slicemut_rangetoinclusive_ok() { + let mut s = "abcαβγ".to_owned(); + let s: &mut str = &mut s; + &mut s[..=3]; // before alpha + &mut s[..=5]; // after alpha +} + +#[test] +#[should_panic] +fn test_str_slicemut_rangetoinclusive_notok() { + let mut s = "abcαβγ".to_owned(); + let s: &mut str = &mut s; + &mut s[..=4]; // middle of alpha, which is 2 bytes long +} + +#[test] fn test_is_char_boundary() { let s = "ศไทย中华Việt Nam β-release 🐱123"; assert!(s.is_char_boundary(0)); |
