feat(test): expose test buffer (#160)

Allow a way to expose the buffer of the `TestBackend`,
to easier support different testing methodologies.
This commit is contained in:
a-kenji 2023-05-04 21:28:55 +02:00 committed by GitHub
parent 5f12f06297
commit 86c3fc9fac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,10 @@ use crate::{
buffer::{Buffer, Cell},
layout::Rect,
};
use std::{fmt::Write, io};
use std::{
fmt::{Display, Write},
io,
};
use unicode_width::UnicodeWidthStr;
/// A backend used for the integration tests.
@ -105,6 +108,12 @@ impl TestBackend {
}
}
impl Display for TestBackend {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", buffer_view(&self.buffer))
}
}
impl Backend for TestBackend {
fn draw<'a, I>(&mut self, content: I) -> Result<(), io::Error>
where