mirror of
https://gitlab.com/arnekeller/ascii-table.git
synced 2024-12-04 21:49:08 +00:00
New validation.
This commit is contained in:
parent
dbf9338335
commit
f501c4ac0c
@ -192,10 +192,10 @@ impl AsciiTable {
|
|||||||
fn valid(&self, data: &Vec<Vec<String>>, num_cols: usize) -> bool {
|
fn valid(&self, data: &Vec<Vec<String>>, num_cols: usize) -> bool {
|
||||||
if data.len() == 0 {
|
if data.len() == 0 {
|
||||||
false
|
false
|
||||||
} else if self.max_width < 4 {
|
|
||||||
false
|
|
||||||
} else if num_cols == 0 {
|
} else if num_cols == 0 {
|
||||||
false
|
false
|
||||||
|
} else if self.max_width < ((num_cols - 1) * 3) + 4 {
|
||||||
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ fn smallest_cell2() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn smallest_cube() {
|
fn smallest_cube() {
|
||||||
let config = AsciiTable {
|
let config = AsciiTable {
|
||||||
max_width: 4,
|
max_width: 10,
|
||||||
..AsciiTable::default()
|
..AsciiTable::default()
|
||||||
};
|
};
|
||||||
let input = vec![&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]];
|
let input = vec![&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]];
|
||||||
@ -233,7 +233,7 @@ fn smallest_cell_with_header2() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn smallest_cube_with_header() {
|
fn smallest_cube_with_header() {
|
||||||
let mut config = AsciiTable {
|
let mut config = AsciiTable {
|
||||||
max_width: 4,
|
max_width: 10,
|
||||||
..AsciiTable::default()
|
..AsciiTable::default()
|
||||||
};
|
};
|
||||||
config.columns.insert(0, Column {header: "abc".to_string(), ..Column::default()});
|
config.columns.insert(0, Column {header: "abc".to_string(), ..Column::default()});
|
||||||
|
Loading…
Reference in New Issue
Block a user