extract pretty string to a module

This commit is contained in:
Abraham Toriz 2021-06-29 12:00:46 -05:00
parent cfcc514fa3
commit d8cd301888
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
3 changed files with 18 additions and 13 deletions

View File

@ -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![

View File

@ -5,3 +5,6 @@ pub mod editor;
pub mod formatters;
pub mod error;
pub mod models;
#[cfg(test)]
pub mod test_utils;

11
src/test_utils.rs Normal file
View File

@ -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)
}
}