From d8cd3018888042baedf5a860eff6fbcdb968976f Mon Sep 17 00:00:00 2001 From: Abraham Toriz Date: Tue, 29 Jun 2021 12:00:46 -0500 Subject: [PATCH] extract pretty string to a module --- src/formatters.rs | 17 ++++------------- src/lib.rs | 3 +++ src/test_utils.rs | 11 +++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 src/test_utils.rs diff --git a/src/formatters.rs b/src/formatters.rs index 5fe76f0..2921ae9 100644 --- a/src/formatters.rs +++ b/src/formatters.rs @@ -214,24 +214,15 @@ impl FromStr for Formatter { #[cfg(test)] mod tests { - use super::*; - use std::fmt; - use pretty_assertions::assert_eq; use chrono::TimeZone; + use crate::test_utils::PrettyString; + + use super::*; + const LONG_NOTE: &'static str = "chatting with bob about upcoming task, district sharing of images, how the user settings currently works etc. Discussing the fingerprinting / cache busting issue with CKEDITOR, suggesting perhaps looking into forking the rubygem and seeing if we can work in our own changes, however hard that might be."; - #[derive(PartialEq, Eq)] - pub struct PrettyString<'a>(pub &'a str); - - /// Make diff to display string as multi-line string - impl<'a> fmt::Debug for PrettyString<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(self.0) - } - } - #[test] fn test_constrained_lines_long_text() { assert_eq!(constrained_lines(LONG_NOTE, 46), vec![ diff --git a/src/lib.rs b/src/lib.rs index 3eb4127..ef131bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,3 +5,6 @@ pub mod editor; pub mod formatters; pub mod error; pub mod models; + +#[cfg(test)] +pub mod test_utils; diff --git a/src/test_utils.rs b/src/test_utils.rs new file mode 100644 index 0000000..ac6c577 --- /dev/null +++ b/src/test_utils.rs @@ -0,0 +1,11 @@ +use std::fmt; + +#[derive(PartialEq, Eq)] +pub struct PrettyString<'a>(pub &'a str); + +/// Make diff to display string as multi-line string +impl<'a> fmt::Debug for PrettyString<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(self.0) + } +}