Skip to content

Commit

Permalink
Merge pull request #455 from zhiburt/patch/testing_table/improve-1
Browse files Browse the repository at this point in the history
testing_table/ Improve error message
  • Loading branch information
zhiburt authored Nov 20, 2024
2 parents 15dbb36 + 81354df commit bb3e0aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tabled/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ ansitok = { version = "0.2", optional = true }

[dev-dependencies]
owo-colors = "3.5"
testing_table = { version = "0.1", features = ["ansi"] }
testing_table = { path = "../testing_table", features = ["ansi"] }

# To run it locally (probably need to `add #![feature(doc_cfg)]` to the crate attributes to enable.
#
Expand Down
4 changes: 2 additions & 2 deletions tabled/tests/settings/alignment_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ test_table!(
padding_by_column_name_not_existing,
Matrix::new(3, 3)
.with(Style::psql())
.with(Modify::new(ByColumnName::new("column 01123123")).with(Padding::new(3, 3, 0, 0)))
.with(Modify::new(Segment::all()).with(Alignment::center())),
.modify(ByColumnName::new("column 01123123"), Padding::new(3, 3, 0, 0))
.with(Alignment::center()),
" N | column 0 | column 1 | column 2 "
"---+----------+----------+----------"
" 0 | 0-0 | 0-1 | 0-2 "
Expand Down
9 changes: 8 additions & 1 deletion testing_table/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ macro_rules! test_table {
macro_rules! assert_table {
($table:expr, $($line:expr)*) => {
let table = $table.to_string();
assert_eq!(table, $crate::static_table!($($line)*));
let expected = $crate::static_table!($($line)*);
assert_eq!(
table,
expected,
"\ngot:\n{}\nexpected:\n{}",
table,
expected,
);
};
}

Expand Down

0 comments on commit bb3e0aa

Please sign in to comment.