mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-01 06:51:15 +00:00
Add unit tests for whitespace splitter
This commit is contained in:
parent
4805acc8eb
commit
bba3950c37
@ -186,3 +186,26 @@ pub fn parse(src: &str) -> Vec<Node> {
|
||||
IResult::Incomplete(_) => panic!("parsing incomplete"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
fn check_ws_split(s: &str, res: &(&[u8], &[u8], &[u8])) {
|
||||
let node = super::split_ws_parts(s.as_bytes());
|
||||
match node {
|
||||
super::Node::Lit(lws, s, rws) => {
|
||||
assert_eq!(lws, res.0);
|
||||
assert_eq!(s, res.1);
|
||||
assert_eq!(rws, res.2);
|
||||
},
|
||||
_ => { panic!("fail"); },
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn test_ws_splitter() {
|
||||
check_ws_split("a", &(b"", b"a", b""));
|
||||
check_ws_split("", &(b"", b"", b""));
|
||||
check_ws_split("\ta", &(b"\t", b"a", b""));
|
||||
check_ws_split("b\n", &(b"", b"b", b"\n"));
|
||||
check_ws_split(" \t\r\n", &(b" \t\r\n", b"", b""));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user