fix my unit test that was horrendously wrong · rust-lang/rust@90b361b (original) (raw)
`@@ -401,20 +401,34 @@ fn test_str_get_maxinclusive() {
`
401
401
`}
`
402
402
`}
`
403
403
``
``
404
`+
#[test]
`
``
405
`+
fn test_str_slice_rangetoinclusive_ok() {
`
``
406
`+
let s = "abcαβγ";
`
``
407
`+
assert_eq!(&s[..=2], "abc");
`
``
408
`+
assert_eq!(&s[..=4], "abcα");
`
``
409
`+
}
`
``
410
+
``
411
`+
#[test]
`
``
412
`+
#[should_panic]
`
``
413
`+
fn test_str_slice_rangetoinclusive_notok() {
`
``
414
`+
let s = "abcαβγ";
`
``
415
`+
&s[..=3];
`
``
416
`+
}
`
``
417
+
404
418
`#[test]
`
405
419
`fn test_str_slicemut_rangetoinclusive_ok() {
`
406
420
`let mut s = "abcαβγ".to_owned();
`
407
421
`let s: &mut str = &mut s;
`
408
``
`-
&mut s[..=3]; // before alpha
`
409
``
`-
&mut s[..=5]; // after alpha
`
``
422
`+
assert_eq!(&mut s[..=2], "abc");
`
``
423
`+
assert_eq!(&mut s[..=4], "abcα");
`
410
424
`}
`
411
425
``
412
426
`#[test]
`
413
427
`#[should_panic]
`
414
428
`fn test_str_slicemut_rangetoinclusive_notok() {
`
415
429
`let mut s = "abcαβγ".to_owned();
`
416
430
`let s: &mut str = &mut s;
`
417
``
`-
&mut s[..=4]; // middle of alpha, which is 2 bytes long
`
``
431
`+
&mut s[..=3];
`
418
432
`}
`
419
433
``
420
434
`#[test]
`