Skip to content

Commit

Permalink
tabled/ fix Builder::push_column cannot create new rows (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n authored Feb 23, 2024
1 parent 4ab897e commit fa06ecf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions tabled/src/builder/table_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl Builder {
}

row.push(text);
self.data.push(row);
}

self.count_columns += 1;
Expand Down
38 changes: 38 additions & 0 deletions tabled/tests/core/builder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,44 @@ test_table!(
"+---+---+---+---+"
);

test_table!(
push_column_2,
{
let mut b = Builder::default();
b.push_column(["a", "d"]);
b.push_column(["b", "e"]);
b.push_column(["c", "f"]);
b.push_column(["g", "h"]);
b.build()
},
"+---+---+---+---+"
"| a | b | c | g |"
"+---+---+---+---+"
"| d | e | f | h |"
"+---+---+---+---+"
);

test_table!(
push_column_3,
{
let mut b = Builder::default();
b.push_column(["a", "d"]);
b.push_column(["b", "e"]);
b.push_column(["c", "f", "f"]);
b.push_column(["g", "h"]);
let a: [&str; 0] = [];
b.push_column(a);
b.build()
},
"+---+---+---+---+--+"
"| a | b | c | g | |"
"+---+---+---+---+--+"
"| d | e | f | h | |"
"+---+---+---+---+--+"
"| | | f | | |"
"+---+---+---+---+--+"
);

test_table!(
insert_column_0,
{
Expand Down

0 comments on commit fa06ecf

Please sign in to comment.