Skip to content

Commit

Permalink
refactor(buffer): deprecate assert_buffer_eq! in favor of assert_eq! (#…
Browse files Browse the repository at this point in the history
…1007)

- Simplify `assert_buffer_eq!` logic.
- Deprecate `assert_buffer_eq!`.
- Introduce `TestBackend::assert_buffer_lines`.

Also simplify many tests involving buffer comparisons.

For the deprecation, just use `assert_eq` instead of `assert_buffer_eq`:

```diff
-assert_buffer_eq!(actual, expected);
+assert_eq!(actual, expected);
```

---

I noticed `assert_buffer_eq!` creating no test coverage reports and
looked into this macro. First I simplified it. Then I noticed a bunch of
`assert_eq!(buffer, …)` and other indirect usages of this macro (like
`TestBackend::assert_buffer`).

The good thing here is that it's mainly used in tests so not many
changes to the library code.
  • Loading branch information
EdJoPaTo committed May 14, 2024
1 parent 1a4bb1c commit 2cfe82a
Show file tree
Hide file tree
Showing 40 changed files with 2,970 additions and 3,842 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ cassowary = "0.3"
compact_str = "0.7.1"
crossterm = { version = "0.27", optional = true }
document-features = { version = "0.2.7", optional = true }
indoc = "2.0"
itertools = "0.12"
lru = "0.12.0"
paste = "1.0.2"
serde = { version = "1", optional = true, features = ["derive"] }
stability = "0.2.0"
strum = { version = "0.26", features = ["derive"] }
time = { version = "0.3.11", optional = true, features = ["local-offset"] }
termion = { version = "3.0", optional = true }
termwiz = { version = "0.22.0", optional = true }
time = { version = "0.3.11", optional = true, features = ["local-offset"] }
unicode-segmentation = "1.10"
unicode-truncate = "1"
unicode-width = "0.1"
Expand All @@ -56,6 +55,7 @@ criterion = { version = "0.5.1", features = ["html_reports"] }
derive_builder = "0.20.0"
fakeit = "1.1"
font8x8 = "0.3.1"
indoc = "2"
palette = "0.7.3"
pretty_assertions = "1.4.0"
rand = "0.8.5"
Expand Down
4 changes: 2 additions & 2 deletions examples/barchart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ fn draw_legend(f: &mut Frame, area: Rect) {
"- Company B",
Style::default().fg(Color::Yellow),
)),
Line::from(vec![Span::styled(
Line::from(Span::styled(
"- Company C",
Style::default().fg(Color::White),
)]),
)),
];

let block = Block::bordered().style(Style::default().fg(Color::White));
Expand Down
134 changes: 64 additions & 70 deletions examples/demo2/big_text.rs

Large diffs are not rendered by default.

0 comments on commit 2cfe82a

Please sign in to comment.