[][src]Macro writeable::assert_writeable_eq

macro_rules! assert_writeable_eq {
    ($expected_str:expr, $actual_writeable:expr) => { ... };
}

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.

Example

use writeable::Writeable;
use writeable::assert_writeable_eq;
use std::fmt;

struct Demo;
impl Writeable for Demo {
    fn write_to(&self, sink: &mut dyn fmt::Write) -> fmt::Result {
        sink.write_str("foo")
    }
    fn write_len(&self) -> usize {
        3
    }
}

assert_writeable_eq!("foo", &Demo);