From f501c4ac0cd700e56eb9635936204d8f8dd33306 Mon Sep 17 00:00:00 2001 From: Gerrit Viljoen Date: Thu, 2 Apr 2020 09:09:30 +0200 Subject: [PATCH] New validation. --- src/lib.rs | 4 ++-- src/test.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e889029..3763d73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -192,10 +192,10 @@ impl AsciiTable { fn valid(&self, data: &Vec>, num_cols: usize) -> bool { if data.len() == 0 { false - } else if self.max_width < 4 { - false } else if num_cols == 0 { false + } else if self.max_width < ((num_cols - 1) * 3) + 4 { + false } else { true } diff --git a/src/test.rs b/src/test.rs index dbc55b0..7f86836 100644 --- a/src/test.rs +++ b/src/test.rs @@ -118,7 +118,7 @@ fn smallest_cell2() { #[test] fn smallest_cube() { let config = AsciiTable { - max_width: 4, + max_width: 10, ..AsciiTable::default() }; let input = vec![&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]]; @@ -233,7 +233,7 @@ fn smallest_cell_with_header2() { #[test] fn smallest_cube_with_header() { let mut config = AsciiTable { - max_width: 4, + max_width: 10, ..AsciiTable::default() }; config.columns.insert(0, Column {header: "abc".to_string(), ..Column::default()});