Skip to content

Commit 123d6c8

Browse files
committed
add regression tests for #236
1 parent f2c5951 commit 123d6c8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/slice/tests.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,32 @@ fn copying() {
7575
}
7676
}
7777

78+
// regression tests for #236
79+
#[test]
80+
fn copy_within_supports_empty_ranges() {
81+
let empty = bits![mut u8, Lsb0; 0; 0];
82+
empty.copy_within(0..0, 0);
83+
assert_eq!(empty, bits![]);
84+
85+
let non_empty = bits![mut u8, Lsb0; 0; 3];
86+
non_empty.copy_within(2..2, 0);
87+
assert_eq!(non_empty, bits![0, 0, 0]);
88+
}
89+
#[test]
90+
#[should_panic]
91+
fn copy_within_panics_if_empty_range_exceeds_bounds() {
92+
let empty_slice = bits![mut u8, Lsb0; 0; 0];
93+
empty_slice.copy_within(2..2, 0);
94+
}
95+
#[test]
96+
#[should_panic]
97+
fn copy_within_panics_if_dest_for_empty_range_exceeds_bounds() {
98+
let empty_slice = bits![mut u8, Lsb0; 0; 0];
99+
empty_slice.copy_within(0..0, 1);
100+
}
101+
102+
103+
78104
#[test]
79105
fn writing() {
80106
let bits = bits![mut 0; 2];

0 commit comments

Comments
 (0)