ratatui/tests/border_macro.rs
Orhun Parmaksız ef8bc7c5a8
feat(border): add border! macro for easy bitflag manipulation (#11)
Adds a `border!` macro that takes TOP, BOTTOM, LEFT, RIGHT, and ALL and
returns a Borders object. An empty `border!()` call returns
Borders::NONE

This is gated behind a `macros` feature flag to ensure short build
times. To enable, add the following to your `Cargo.toml`:

```toml
ratatui = { version = 0.21.0, features = ["macros"] }
```

Co-authored-by: C-Jameson <booksncode@gmail.com>
2023-05-21 15:26:39 -07:00

19 lines
505 B
Rust

#![cfg(feature = "macros")]
use ratatui::{border, widgets::Borders};
#[test]
fn border_empty_test() {
let empty = Borders::NONE;
assert_eq!(empty, border!());
}
#[test]
fn border_all_test() {
let all = Borders::ALL;
assert_eq!(all, border!(ALL));
assert_eq!(all, border!(TOP, BOTTOM, LEFT, RIGHT));
}
#[test]
fn border_left_right_test() {
let left_right = Borders::from_bits(Borders::LEFT.bits() | Borders::RIGHT.bits());
assert_eq!(left_right, Some(border!(RIGHT, LEFT)));
}