Skip to content

Commit

Permalink
add regression tests for ferrilab#236
Browse files Browse the repository at this point in the history
  • Loading branch information
cmrschwarz committed Jul 29, 2023
1 parent f21463d commit 3da24a0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/slice/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ fn copying() {
}
}

// regression tests for #236
#[test]
fn copy_within_supports_empty_ranges() {
let empty = bits![mut u8, Lsb0; 0; 0];
empty.copy_within(0..0, 0);
assert_eq!(empty, bits![]);

let non_empty = bits![mut u8, Lsb0; 0; 3];
non_empty.copy_within(2..2, 0);
assert_eq!(non_empty, bits![0, 0, 0]);
}
#[test]
#[should_panic]
fn copy_within_panics_if_empty_range_exceeds_bounds() {
let empty_slice = bits![mut u8, Lsb0; 0; 0];
empty_slice.copy_within(2..2, 0);
}
#[test]
#[should_panic]
fn copy_within_panics_if_dest_for_empty_range_exceeds_bounds() {
let empty_slice = bits![mut u8, Lsb0; 0; 0];
empty_slice.copy_within(0..0, 1);
}


#[test]
fn writing() {
let bits = bits![mut 0; 2];
Expand Down

0 comments on commit 3da24a0

Please sign in to comment.