extract pretty string to a module
This commit is contained in:
parent
cfcc514fa3
commit
d8cd301888
|
@ -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![
|
||||
|
|
|
@ -5,3 +5,6 @@ pub mod editor;
|
|||
pub mod formatters;
|
||||
pub mod error;
|
||||
pub mod models;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test_utils;
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue