pub struct TestBackend { /* private fields */ }Expand description
A test backend for unit testing and snapshot testing.
Records operations and maintains a virtual terminal buffer.
§Example
use tuxtui_core::backend::{Backend, TestBackend};
use tuxtui_core::geometry::Rect;
let mut backend = TestBackend::new(80, 24);
backend.clear().unwrap();
let size = backend.size().unwrap();
assert_eq!(size.width, 80);
assert_eq!(size.height, 24);Implementations§
Source§impl TestBackend
impl TestBackend
Sourcepub fn new(width: u16, height: u16) -> Self
pub fn new(width: u16, height: u16) -> Self
Create a new test backend with the given dimensions.
Sourcepub fn buffer_mut(&mut self) -> &mut Buffer
pub fn buffer_mut(&mut self) -> &mut Buffer
Get a mutable reference to the buffer.
Sourcepub const fn is_cursor_visible(&self) -> bool
pub const fn is_cursor_visible(&self) -> bool
Get the cursor visibility state.
Sourcepub fn assert_buffer_equals(&self, expected: &str)
pub fn assert_buffer_equals(&self, expected: &str)
Assert that the buffer contains the expected string at the given position.
§Panics
Panics if the buffer content doesn’t match.
Trait Implementations§
Source§impl Backend for TestBackend
impl Backend for TestBackend
Source§type Error = TestBackendError
type Error = TestBackendError
The error type for this backend.
Source§fn draw_cell(&mut self, x: u16, y: u16, cell: &Cell) -> Result<(), Self::Error>
fn draw_cell(&mut self, x: u16, y: u16, cell: &Cell) -> Result<(), Self::Error>
Draw a single cell at the given position.
Source§fn set_style(&mut self, _style: Style) -> Result<(), Self::Error>
fn set_style(&mut self, _style: Style) -> Result<(), Self::Error>
Set the current style for subsequent operations.
Auto Trait Implementations§
impl Freeze for TestBackend
impl RefUnwindSafe for TestBackend
impl Send for TestBackend
impl Sync for TestBackend
impl Unpin for TestBackend
impl UnwindSafe for TestBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more