Skip to content

Commit

Permalink
feat(test): expose test buffer
Browse files Browse the repository at this point in the history
Allow a way to expose the buffer of the `TestBackend`,
to easier support different testing methodologies.
  • Loading branch information
a-kenji committed May 1, 2023
1 parent 37bb82e commit d64f183
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/backend/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
buffer::{Buffer, Cell},
layout::Rect,
};
use std::{fmt::Write, io};
use std::{fmt::{Write, Display}, io};
use unicode_width::UnicodeWidthStr;

/// A backend used for the integration tests.
Expand Down Expand Up @@ -105,6 +105,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
Expand Down

0 comments on commit d64f183

Please sign in to comment.