Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(buffer): allow with_lines to accept Vec<Into<Line>> #494

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

joshka
Copy link
Member

@joshka joshka commented Sep 12, 2023

This allows writing unit tests without having to call set_style on the
expected buffer.

E.g.:

use crate::style::Stylize;
let mut buf = Buffer::empty(Rect::new(0, 0, 10, 10));
buf.set_string(0, 0, "foo", Style::new().red());
buf.set_string(0, 1, "bar", Style::new().blue());
assert_eq!(buf, Buffer::with_lines(vec!["foo".red(), "bar".blue()]));

Inspired by #493 (comment)

This allows writing unit tests without having to call set_style on the
expected buffer.

E.g.:
```rust
use crate::style::Stylize;
let mut buf = Buffer::empty(Rect::new(0, 0, 10, 10));
buf.set_string(0, 0, "foo", Style::new().red());
buf.set_string(0, 1, "bar", Style::new().blue());
assert_eq!(buf, Buffer::with_lines(vec!["foo".red(), "bar".blue()]));
```

Inspired by #493 (comment)
@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Merging #494 (a54c371) into main (42f8169) will decrease coverage by 0.28%.
The diff coverage is 42.66%.

@@            Coverage Diff             @@
##             main     #494      +/-   ##
==========================================
- Coverage   90.16%   89.89%   -0.28%     
==========================================
  Files          41       41              
  Lines       11277    11286       +9     
==========================================
- Hits        10168    10145      -23     
- Misses       1109     1141      +32     
Files Changed Coverage Δ
src/widgets/list.rs 95.20% <10.00%> (-3.09%) ⬇️
src/widgets/tabs.rs 85.51% <44.82%> (-1.75%) ⬇️
src/buffer.rs 94.06% <100.00%> (ø)
src/layout.rs 98.29% <100.00%> (+<0.01%) ⬆️

@joshka joshka merged commit 94af2a2 into main Sep 12, 2023
31 of 33 checks passed
@joshka joshka deleted the buffer-with-lines branch September 12, 2023 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants