Macro writeable::assert_writeable_eq [−][src]
macro_rules! assert_writeable_eq { ($expected_str:expr, $actual_writeable:expr $(,)?) => { ... }; ($expected_str:expr, $actual_writeable:expr, $($arg:tt)+) => { ... }; }
Testing macro for types implementing Writeable. The first argument should be a string, and
the second argument should be a &dyn Writeable
.
The macro tests for equality of both string content and string length. If your Writeable implementation returns an inexact string length, don’t use this macro.
Examples
use writeable::Writeable; use writeable::LengthHint; use writeable::assert_writeable_eq; use std::fmt; struct Demo; impl Writeable for Demo { fn write_to<W: fmt::Write + ?Sized>(&self, sink: &mut W) -> fmt::Result { sink.write_str("foo") } fn write_len(&self) -> LengthHint { LengthHint::Exact(3) } } assert_writeable_eq!("foo", &Demo); assert_writeable_eq!("foo", &Demo, "Message: {}", "Hello World");