extern crate rustache;
use rustache::{HashBuilder, Render};
use std::io::Cursor;
#[test]
fn test_spec_inline_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("12345{{! Comment Block! }}67890", &mut rv).unwrap();
assert_eq!("1234567890".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_multiline_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("12345{{!\nThis is a\nmulti-line comment...\n}}67890", &mut rv).unwrap();
assert_eq!("1234567890".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_standalone_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("Begin.\n{{! Comment Block! }}\nEnd.", &mut rv).unwrap();
assert_eq!("Begin.\nEnd.".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_indented_standalone_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("Begin.\n\t{{! Indented Comment Block! }}\nEnd.", &mut rv).unwrap();
assert_eq!("Begin.\nEnd.".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_standalone_line_ending_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("|\r\n{{! Standalone Comment }}\r\n|", &mut rv).unwrap();
assert_eq!("|\r\n|".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
#[ignore]
fn test_spec_standalone_without_prev_line_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render(" {{! I'm Still Standalone }}\n!", &mut rv).unwrap();
assert_eq!("!".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
#[ignore]
fn test_spec_standalone_without_newline_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("!\n {{! I'm Still Standalone }}", &mut rv).unwrap();
assert_eq!("!\n".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_multiline_standalone_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("Begin.\n{{!\nSomething's going on here...\n}}\nEnd.", &mut rv).unwrap();
assert_eq!("Begin.\nEnd.".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_indented_multiline_standalone_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("Begin.\n{{!\n\tSomething's going on here...\n}}\nEnd.", &mut rv).unwrap();
assert_eq!("Begin.\nEnd.".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_indented_inline_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render(" 12 {{! 34 }}\n", &mut rv).unwrap();
assert_eq!(" 12 \n".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}
#[test]
fn test_spec_surrounding_whitespace_comment() {
let data = HashBuilder::new();
let mut rv = Cursor::new(Vec::new());
data.render("12345 {{! Comment Block! }} 67890", &mut rv).unwrap();
assert_eq!("12345 67890".to_string(), String::from_utf8(rv.into_inner()).unwrap());
}