#[cfg(test)]
mod tests {
use crate::test_helpers::*;
#[test]
fn test_bif_bool() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; __test-nts >> nts :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>nts</div>");
}
#[test]
fn test_bif_bool_obj_levels() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; __test-obj-nts->level1-obj->level2-obj->level2 >> {:;__test-obj-nts->level1-obj->level2-obj->level2:} :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>Ok</div>");
}
#[test]
fn test_bif_bool_evaluate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; __test-{:;__test-nts:} >> {:;__test-nts:} :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>nts</div>");
}
#[test]
fn test_bif_bool_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; __test-bool-false-string-nts >> nts :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>nts</div>");
}
#[test]
fn test_bif_bool_negate_undefined() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; undefined-var >> nts :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>nts</div>");
}
#[test]
fn test_bif_bool_obj() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; __test-obj_nts >> nts :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>nts</div>");
}
#[test]
fn test_bif_bool_obj_empty_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; __test-obj-empty-nts >> nts :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>nts</div>");
}
#[test]
fn test_bif_bool_obj_empty() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; __test-obj-empty-nts >> nts :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_scope() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:+bool; __test-nts >> {:include; tests/snippets.ntpl :} :}{:snippet; test-snippet :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div><div>test snippet</div></div>");
}
#[test]
fn test_bif_bool_no_scope() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; __test-nts >> {:include; tests/snippets.ntpl :} :}{:snippet; test-snippet :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_true() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; true >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_false() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; false >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_text() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; text >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_zero() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; zero >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_one() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; one >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_spaces() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; spaces >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_empty() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; empty >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_null() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; null >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_emptyarr() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; emptyarr >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_array() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_true_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::true >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_false_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::false >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_text_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::text >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_zero_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::zero >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_one_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::one >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_spaces_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::spaces >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_empty_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::empty >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_null_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::null >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_emptyarr_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::emptyarr >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_array_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_true_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; true >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_false_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; false >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_text_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; text >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_zero_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; zero >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_one_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; one >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_spaces_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; spaces >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_empty_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; empty >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_null_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; null >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_emptyarr_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; emptyarr >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_array_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_true_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::true >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_false_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::false >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_text_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::text >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_zero_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::zero >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_one_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::one >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_spaces_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::spaces >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_empty_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::empty >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_null_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::null >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_emptyarr_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::emptyarr >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_array_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:!bool; local::array >> is not bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_true() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->true >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_false() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->false >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_text() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->text >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_zero() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->zero >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_one() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->one >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_spaces() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->spaces >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_empty() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->empty >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_null() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; array->null >> is bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_true_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->true >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_false_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->false >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_text_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->text >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_zero_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->zero >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_one_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->one >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_spaces_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->spaces >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is bool</div>");
}
#[test]
fn test_bif_bool_arr_empty_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->empty >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_null_local() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str(
"<div>{:data; tests/local-data.json :}{:bool; local::array->null >> is bool :}</div>",
);
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_true_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->true >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_false_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->false >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_text_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->text >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_zero_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->zero >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_one_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->one >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_spaces_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->spaces >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_empty_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->empty >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_null_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:!bool; array->null >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_true_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->true >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_false_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->false >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_text_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->text >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_zero_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->zero >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_one_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->one >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_spaces_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->spaces >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div></div>");
}
#[test]
fn test_bif_bool_arr_empty_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->empty >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_arr_null_local_negate() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:data; tests/local-data.json :}{:!bool; local::array->null >> is not bool :}</div>");
let result = template.render();
assert!(!template.has_error());
assert_eq!(result, "<div>is not bool</div>");
}
#[test]
fn test_bif_bool_flags_not_allowed() {
let mut template = match crate::Template::new() {
Ok(tpl) => tpl,
Err(error) => {
println!("Error creating Template: {}", error);
assert!(false);
return;
}
};
template.merge_schema_str(SCHEMA).unwrap();
template.set_src_str("<div>{:bool; {:flg; invalid_flag :} true >> nts :}</div>");
let result = template.render();
assert!(template.has_error());
assert_eq!(result, "<div></div>");
}
}