diff --git a/src/utils/lines/simple/mod.rs b/src/utils/lines/simple/mod.rs index 8872215..7ad085f 100644 --- a/src/utils/lines/simple/mod.rs +++ b/src/utils/lines/simple/mod.rs @@ -37,7 +37,7 @@ pub struct Span { /// extern crate unicode_segmentation; /// use unicode_segmentation::UnicodeSegmentation; /// -/// # use cursive::utils::prefix; +/// # use cursive::utils::lines::simple::prefix; /// # fn main() { /// let my_text = "blah..."; /// // This returns the number of bytes for a prefix of `my_text` that @@ -109,3 +109,15 @@ pub fn simple_suffix(text: &str, width: usize) -> Span { pub fn simple_prefix(text: &str, width: usize) -> Span { prefix(text.graphemes(true), width, "") } + +#[cfg(test)] +mod tests { + use super::prefix; + + #[test] + fn test_prefix() { + assert_eq!(prefix(" abra ".split(' '), 5, " ").length, 5); + assert_eq!(prefix("abra a".split(' '), 5, " ").length, 4); + assert_eq!(prefix("a a br".split(' '), 5, " ").length, 3); + } +} diff --git a/src/utils/lines/spans/segment.rs b/src/utils/lines/spans/segment.rs index b5cba4c..62d4513 100644 --- a/src/utils/lines/spans/segment.rs +++ b/src/utils/lines/spans/segment.rs @@ -16,7 +16,7 @@ pub struct Segment { impl Segment { #[cfg(test)] - fn with_text<'a>(self, text: &'a str) -> SegmentWithText<'a> { + pub fn with_text<'a>(self, text: &'a str) -> SegmentWithText<'a> { SegmentWithText { text, seg: self } } } diff --git a/src/utils/lines/spans/tests.rs b/src/utils/lines/spans/tests.rs index eac538c..d45647d 100644 --- a/src/utils/lines/spans/tests.rs +++ b/src/utils/lines/spans/tests.rs @@ -1,4 +1,13 @@ -use super::*; +use theme::Style; +use super::Span; +use super::chunk::Chunk; +use super::row::Row; +use super::chunk_iterator::ChunkIterator; +use super::segment::Segment; + +use super::SpanLinesIterator; + +use std::borrow::Cow; fn input() -> Vec> { vec![ diff --git a/src/utils/mod.rs b/src/utils/mod.rs index fcfe8f1..9a83125 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -4,15 +4,3 @@ mod reader; pub mod lines; pub use self::reader::ProgressReader; - -#[cfg(test)] -mod tests { - use utils; - - #[test] - fn test_prefix() { - assert_eq!(utils::prefix(" abra ".split(' '), 5, " ").length, 5); - assert_eq!(utils::prefix("abra a".split(' '), 5, " ").length, 4); - assert_eq!(utils::prefix("a a br".split(' '), 5, " ").length, 3); - } -}