Skip to content

Commit

Permalink
fix: new clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Aug 5, 2024
1 parent b4b5963 commit e59a315
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 67 deletions.
6 changes: 3 additions & 3 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,19 +859,19 @@ mod tests {
#[test]
fn test_column_generation() {
let mut table = Table::new();
table.set_header(&vec!["thr", "four", "fivef"]);
table.set_header(vec!["thr", "four", "fivef"]);

// When adding a new row, columns are automatically generated
assert_eq!(table.columns.len(), 3);
// The max content width is also correctly set for each column
assert_eq!(table.column_max_content_widths(), vec![3, 4, 5]);

// When adding a new row, the max content width is updated accordingly
table.add_row(&vec!["four", "fivef", "very long text with 23"]);
table.add_row(vec!["four", "fivef", "very long text with 23"]);
assert_eq!(table.column_max_content_widths(), vec![4, 5, 22]);

// Now add a row that has column lines. The max content width shouldn't change
table.add_row(&vec!["", "", "shorter"]);
table.add_row(vec!["", "", "shorter"]);
assert_eq!(table.column_max_content_widths(), vec![4, 5, 22]);

println!("{table}");
Expand Down
6 changes: 3 additions & 3 deletions src/utils/arrangement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ mod tests {
#[test]
fn test_disabled_arrangement() {
let mut table = Table::new();
table.set_header(&vec!["head", "head", "head"]);
table.add_row(&vec!["__", "fivef", "sixsix"]);
table.set_header(vec!["head", "head", "head"]);
table.add_row(vec!["__", "fivef", "sixsix"]);

let display_infos = arrange_content(&table);

Expand All @@ -77,7 +77,7 @@ mod tests {
#[test]
fn test_discover_columns() {
let mut table = Table::new();
table.add_row(&vec!["one", "two"]);
table.add_row(vec!["one", "two"]);

// Get the first row and add a new cell, which would create a new column.
let row = table.row_mut(0).unwrap();
Expand Down
28 changes: 14 additions & 14 deletions tests/all/add_predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use comfy_table::*;
fn add_predicate_single_true() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
Expand Down Expand Up @@ -39,8 +39,8 @@ fn add_predicate_single_true() {
fn add_predicate_single_false() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
Expand Down Expand Up @@ -68,8 +68,8 @@ fn add_predicate_single_false() {
fn add_predicate_single_mixed() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
Expand Down Expand Up @@ -105,8 +105,8 @@ fn add_predicate_single_mixed() {
fn add_predicate_single_wrong_row_count() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
Expand Down Expand Up @@ -147,7 +147,7 @@ fn add_predicate_multi_true() {
];

table
.set_header(&vec!["Header1", "Header2", "Header3"])
.set_header(vec!["Header1", "Header2", "Header3"])
.add_rows_if(|_, _| true, rows);

println!("{table}");
Expand All @@ -168,8 +168,8 @@ fn add_predicate_multi_true() {
fn add_predicate_multi_false() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
Expand Down Expand Up @@ -210,7 +210,7 @@ fn add_predicate_multi_mixed() {
];

table
.set_header(&vec!["Header1", "Header2", "Header3"])
.set_header(vec!["Header1", "Header2", "Header3"])
.add_rows_if(|_, _| true, rows)
.add_rows_if(
|_, _| false,
Expand Down Expand Up @@ -239,8 +239,8 @@ fn add_predicate_multi_mixed() {
fn add_predicate_multi_wrong_rows_count() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
Expand Down
10 changes: 5 additions & 5 deletions tests/all/constraints_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use super::assert_table_line_width;
fn get_constraint_table() -> Table {
let mut table = Table::new();
table
.set_header(&vec!["smol", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["smol", "Header2", "Header3"])
.add_row(vec![
"smol",
"This is another text",
"This is the third text",
])
.add_row(&vec![
.add_row(vec![
"smol",
"Now\nadd some\nmulti line stuff",
"This is awesome",
Expand Down Expand Up @@ -213,8 +213,8 @@ fn percentage() {
fn max_100_percentage() {
let mut table = Table::new();
table
.set_header(&vec!["smol"])
.add_row(&vec!["smol"])
.set_header(vec!["smol"])
.add_row(vec!["smol"])
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(40)
.set_constraints(vec![Absolute(Percentage(200))]);
Expand Down
24 changes: 12 additions & 12 deletions tests/all/content_arrangement_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ use super::assert_table_line_width;
#[test]
fn simple_dynamic_table() {
let mut table = Table::new();
table.set_header(&vec!["Header1", "Header2", "Head"])
table.set_header(vec!["Header1", "Header2", "Head"])
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(25)
.add_row(&vec![
.add_row(vec![
"This is a very long line with a lot of text",
"This is anotherverylongtextwithlongwords text",
"smol",
])
.add_row(&vec![
.add_row(vec![
"This is another text",
"Now let's\nadd a really long line in the middle of the cell \n and add more multi line stuff",
"smol",
Expand Down Expand Up @@ -88,7 +88,7 @@ fn table_with_truncate() {
second_row.max_height(4);

table
.set_header(&vec!["Header1", "Header2", "Head"])
.set_header(vec!["Header1", "Header2", "Head"])
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(35)
.add_row(first_row)
Expand Down Expand Up @@ -132,10 +132,10 @@ fn table_with_truncate() {
fn distribute_space_after_split() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Head"])
.set_header(vec!["Header1", "Header2", "Head"])
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(80)
.add_row(&vec![
.add_row(vec![
"This is a very long line with a lot of text",
"This is text with a anotherverylongtexttesttest",
"smol",
Expand All @@ -161,10 +161,10 @@ fn distribute_space_after_split() {
fn unused_space_after_split() {
let mut table = Table::new();
table
.set_header(&vec!["Header1"])
.set_header(vec!["Header1"])
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(30)
.add_row(&vec!["This is text with a anotherverylongtext"]);
.add_row(vec!["This is text with a anotherverylongtext"]);

println!("{table}");
let expected = "
Expand All @@ -184,10 +184,10 @@ fn unused_space_after_split() {
fn dynamic_full_width_after_split() {
let mut table = Table::new();
table
.set_header(&vec!["Header1"])
.set_header(vec!["Header1"])
.set_content_arrangement(ContentArrangement::DynamicFullWidth)
.set_width(50)
.add_row(&vec!["This is text with a anotherverylongtexttesttestaa"]);
.add_row(vec!["This is text with a anotherverylongtexttesttestaa"]);

println!("{table}");
let expected = "
Expand All @@ -209,10 +209,10 @@ fn dynamic_full_width_after_split() {
fn dynamic_full_width() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "smol"])
.set_header(vec!["Header1", "Header2", "smol"])
.set_content_arrangement(ContentArrangement::DynamicFullWidth)
.set_width(80)
.add_row(&vec!["This is a short line", "small", "smol"]);
.add_row(vec!["This is a short line", "small", "smol"]);

println!("{table}");
let expected = "
Expand Down
4 changes: 2 additions & 2 deletions tests/all/custom_delimiter_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ fn full_custom_delimiters() {
let mut table = Table::new();

table
.set_header(&vec!["Header1", "Header2"])
.set_header(vec!["Header1", "Header2"])
.set_content_arrangement(ContentArrangement::Dynamic)
.set_delimiter('-')
.set_width(40)
.add_row(&vec![
.add_row(vec![
"This shouldn't be split with any logic, since there's no matching delimiter",
"Test-Test-Test-Test-Test-This_should_only_be_splitted_by_underscore_and not by space or hyphens",
]);
Expand Down
6 changes: 3 additions & 3 deletions tests/all/hidden_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn get_table() -> Table {
let mut table = Table::new();
table
.load_preset(presets::UTF8_FULL)
.set_header(&vec![
.set_header(vec![
"hidden_header",
"smol",
"hidden_header",
Expand All @@ -14,7 +14,7 @@ fn get_table() -> Table {
"Header3",
"hidden_header",
])
.add_row(&vec![
.add_row(vec![
"start_hidden",
"smol",
"middle_hidden",
Expand All @@ -23,7 +23,7 @@ fn get_table() -> Table {
"This is the third text",
"end_hidden",
])
.add_row(&vec![
.add_row(vec![
"asdf",
"smol",
"asdf",
Expand Down
6 changes: 3 additions & 3 deletions tests/all/modifiers_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use comfy_table::*;
fn get_preset_table() -> Table {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec!["One One", "One Two", "One Three"])
.add_row(&vec!["One One", "One Two", "One Three"]);
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec!["One One", "One Two", "One Three"])
.add_row(vec!["One One", "One Two", "One Three"]);

table
}
Expand Down
6 changes: 3 additions & 3 deletions tests/all/padding_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ fn custom_padding() {
Cell::new("Header2"),
Cell::new("Header3"),
])
.add_row(&vec!["One One", "One Two", "One Three"])
.add_row(&vec!["Two One", "Two Two", "Two Three"])
.add_row(&vec!["Three One", "Three Two", "Three Three"]);
.add_row(vec!["One One", "One Two", "One Three"])
.add_row(vec!["Two One", "Two Two", "Two Three"])
.add_row(vec!["Three One", "Three Two", "Three Three"]);

let column = table.column_mut(0).unwrap();
column.set_padding((5, 5));
Expand Down
6 changes: 3 additions & 3 deletions tests/all/presets_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use comfy_table::*;
fn get_preset_table() -> Table {
let mut table = Table::new();
table
.set_header(&vec!["Hello", "there"])
.add_row(&vec!["a", "b"])
.add_row(&vec!["c", "d"]);
.set_header(vec!["Hello", "there"])
.add_row(vec!["a", "b"])
.add_row(vec!["c", "d"]);

table
}
Expand Down
22 changes: 11 additions & 11 deletions tests/all/simple_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use comfy_table::*;
fn simple_table() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
])
.add_row(&vec![
.add_row(vec![
"This is another text",
"Now\nadd some\nmulti line stuff",
"This is awesome",
Expand All @@ -36,10 +36,10 @@ fn simple_table() {
fn missing_column_table() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec!["One One", "One Two", "One Three"])
.add_row(&vec!["Two One", "Two Two"])
.add_row(&vec!["Three One"]);
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec!["One One", "One Two", "One Three"])
.add_row(vec!["Two One", "Two Two"])
.add_row(vec!["Three One"]);

println!("{table}");
let expected = "
Expand All @@ -59,10 +59,10 @@ fn missing_column_table() {
fn single_column_table() {
let mut table = Table::new();
table
.set_header(&vec!["Header1"])
.add_row(&vec!["One One"])
.add_row(&vec!["Two One"])
.add_row(&vec!["Three One"]);
.set_header(vec!["Header1"])
.add_row(vec!["One One"])
.add_row(vec!["Two One"])
.add_row(vec!["Three One"]);

println!("{table}");
let expected = "
Expand Down
10 changes: 5 additions & 5 deletions tests/all/utf_8_characters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use comfy_table::*;
fn multi_character_utf8_symbols() {
let mut table = Table::new();
table
.set_header(&vec!["Header1", "Header2", "Header3"])
.add_row(&vec![
.set_header(vec!["Header1", "Header2", "Header3"])
.add_row(vec![
"This is a text",
"This is another text",
"This is the third text",
])
.add_row(&vec![
.add_row(vec![
"This is another text",
"Now\nadd some\nmulti line stuff",
"✅",
Expand All @@ -41,8 +41,8 @@ fn multi_character_utf8_word_splitting() {
table
.set_width(8)
.set_content_arrangement(ContentArrangement::Dynamic)
.set_header(&vec!["test"])
.add_row(&vec!["abc✅def"]);
.set_header(vec!["test"])
.add_row(vec!["abc✅def"]);

println!("{table}");
let expected = "
Expand Down

0 comments on commit e59a315

Please sign in to comment.