mirror of
https://github.com/uutils/uutils-term-grid.git
synced 2026-06-10 16:13:01 -07:00
fix widths for fallback to single column
This commit is contained in:
+1
-1
@@ -114,7 +114,7 @@ impl<T: AsRef<str>> Grid<T> {
|
||||
|
||||
grid.dimensions = grid.width_dimensions(width).unwrap_or(Dimensions {
|
||||
num_lines: grid.cells.len(),
|
||||
widths: grid.widths.clone(),
|
||||
widths: vec![widest_cell_width],
|
||||
});
|
||||
|
||||
grid
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore underflowed
|
||||
|
||||
use term_grid::{Direction, Filling, Grid, GridOptions};
|
||||
|
||||
#[test]
|
||||
@@ -187,6 +189,24 @@ fn emoji() {
|
||||
assert_eq!("🦀 hello\n👩🔬 hello\n", grid.to_string());
|
||||
}
|
||||
|
||||
// This test once underflowed, which should never happen. The test is just
|
||||
// checking that we do not get a panic.
|
||||
#[test]
|
||||
fn possible_underflow() {
|
||||
let cells: Vec<_> = (0..48).map(|i| 2_isize.pow(i).to_string()).collect();
|
||||
|
||||
let grid = Grid::new(
|
||||
cells,
|
||||
GridOptions {
|
||||
direction: Direction::TopToBottom,
|
||||
filling: Filling::Text(" | ".into()),
|
||||
width: 15,
|
||||
},
|
||||
);
|
||||
|
||||
println!("{}", grid);
|
||||
}
|
||||
|
||||
// These test are based on the tests in uutils ls, to ensure we won't break
|
||||
// it while editing this library.
|
||||
mod uutils_ls {
|
||||
|
||||
Reference in New Issue
Block a user