Skip to content

Commit

Permalink
Increase test coverage of packed_array.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
cschwan committed Oct 4, 2024
1 parent 9d63ba7 commit 6e3a578
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pineappl/src/packed_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ mod tests {

array[[1, 0, 0]] = 1;

assert_eq!(array[[0, 0, 0]], 0);
let _ = array[[0, 0, 0]];
}

#[test]
Expand All @@ -812,7 +812,7 @@ mod tests {

array[[1, 0, 0]] = 1;

assert_eq!(array[[2, 0, 0]], 0);
let _ = array[[2, 0, 0]];
}

#[test]
Expand All @@ -822,7 +822,7 @@ mod tests {

array[[1, 0, 0]] = 1;

assert_eq!(array[[1, 50, 0]], 0);
let _ = array[[1, 50, 0]];
}

#[test]
Expand All @@ -832,7 +832,7 @@ mod tests {

array[[0, 0, 1]] = 1;

assert_eq!(array[[0, 0, 0]], 0);
let _ = array[[0, 0, 0]];
}

#[test]
Expand All @@ -842,7 +842,7 @@ mod tests {

array[[0, 0, 1]] = 1;

assert_eq!(array[[0, 0, 2]], 0);
let _ = array[[0, 0, 2]];
}

#[test]
Expand All @@ -856,9 +856,20 @@ mod tests {
let _ = array[super::ravel_multi_index(&[0, 0, 0], &shape)];
}

#[test]
#[should_panic(expected = "entry at index 2 is implicitly set to the default value")]
fn flat_index_panic_2() {
let shape = vec![40, 50, 50];
let mut array = PackedArray::new(shape.clone());

array[[0, 0, 1]] = 1;

let _ = array[super::ravel_multi_index(&[0, 0, 2], &shape)];
}

#[test]
#[should_panic(expected = "index 102550 is out of bounds for array of shape [40, 50, 50]")]
fn flat_index_panic_dim1() {
fn flat_index_panic_102550() {
let shape = vec![40, 50, 50];
let mut array = PackedArray::new(shape.clone());

Expand Down

0 comments on commit 6e3a578

Please sign in to comment.