Skip to content

Commit

Permalink
Fix crash when there is no header and no data (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ch00k authored Mar 16, 2021
1 parent c2d3782 commit 61bcc6d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ pub fn create_list_table<T: Entity>(
}
}
}
let id_column = table.get_column_mut(0).unwrap();
id_column.set_constraint(ColumnConstraint::MinWidth(ID_COLUMN_WIDTH));
if let Some(id_column) = table.get_column_mut(0) {
id_column.set_constraint(ColumnConstraint::MinWidth(ID_COLUMN_WIDTH));
}
table
}

Expand Down Expand Up @@ -555,6 +556,15 @@ mod tests {
);
}

#[test]
fn test_create_list_table_no_header_no_data() {
let data: Vec<Patient> = vec![];
assert_eq!(
format_table(create_list_table(data, None, &PATIENTS_LIST_DICOM_TAGS)),
""
);
}

#[test]
fn test_create_show_table_patient() {
let patient = Patient {
Expand Down

0 comments on commit 61bcc6d

Please sign in to comment.