Add missing imports

This commit is contained in:
Alexandre Bury 2018-01-08 13:14:57 +01:00
parent 2735bf45fd
commit b59e480f60
4 changed files with 24 additions and 15 deletions

View File

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

View File

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

View File

@ -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<Span<'static>> {
vec![

View File

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