2017-05-22 07:48:32 +00:00
|
|
|
use output::cell::TextCell;
|
|
|
|
use output::colours::Colours;
|
|
|
|
use fs::fields as f;
|
|
|
|
|
|
|
|
|
|
|
|
impl f::Blocks {
|
|
|
|
pub fn render(&self, colours: &Colours) -> TextCell {
|
|
|
|
match *self {
|
|
|
|
f::Blocks::Some(ref blk) => TextCell::paint(colours.blocks, blk.to_string()),
|
|
|
|
f::Blocks::None => TextCell::blank(colours.punctuation),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
pub mod test {
|
2017-06-24 21:39:15 +00:00
|
|
|
use output::colours::Colours;
|
2017-05-22 07:48:32 +00:00
|
|
|
use output::cell::TextCell;
|
|
|
|
use fs::fields as f;
|
|
|
|
|
|
|
|
use ansi_term::Colour::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn blocklessness() {
|
2017-06-24 21:39:15 +00:00
|
|
|
let mut colours = Colours::default();
|
|
|
|
colours.punctuation = Green.italic();
|
2017-05-22 07:48:32 +00:00
|
|
|
|
|
|
|
let blox = f::Blocks::None;
|
|
|
|
let expected = TextCell::blank(Green.italic());
|
2017-06-24 21:39:15 +00:00
|
|
|
assert_eq!(expected, blox.render(&colours).into());
|
2017-05-22 07:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn blockfulity() {
|
2017-06-24 21:39:15 +00:00
|
|
|
let mut colours = Colours::default();
|
|
|
|
colours.blocks = Red.blink();
|
2017-05-22 07:48:32 +00:00
|
|
|
|
|
|
|
let blox = f::Blocks::Some(3005);
|
|
|
|
let expected = TextCell::paint_str(Red.blink(), "3005");
|
2017-06-24 21:39:15 +00:00
|
|
|
assert_eq!(expected, blox.render(&colours).into());
|
2017-05-22 07:48:32 +00:00
|
|
|
}
|
|
|
|
}
|