test(headers): Add tests for headers with "*" value

This commit is contained in:
Pyfisch
2015-04-26 14:06:46 +02:00
parent efd6c96a3c
commit 18f717fcf1
4 changed files with 34 additions and 19 deletions

View File

@@ -21,24 +21,21 @@ header! {
#[doc="If-Match = \"*\" / 1#entity-tag"]
#[doc="```"]
(IfMatch, "If-Match") => {Any / (EntityTag)+}
}
#[test]
fn test_parse_header() {
use header::Header;
{
let a: IfMatch = Header::parse_header(
[b"*".to_vec()].as_ref()).unwrap();
assert_eq!(a, IfMatch::Any);
}
{
let a: IfMatch = Header::parse_header(
[b"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\"".to_vec()].as_ref()).unwrap();
let b = IfMatch::Items(
vec![EntityTag::new(false, "xyzzy".to_string()),
EntityTag::new(false, "r2d2xxxx".to_string()),
EntityTag::new(false, "c3piozzzz".to_string())]);
assert_eq!(a, b);
test_if_match {
test_header!(
test1,
vec![b"\"xyzzy\""],
Some(HeaderField::Items(
vec![EntityTag::new(false, "xyzzy".to_string())])));
test_header!(
test2,
vec![b"\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\""],
Some(HeaderField::Items(
vec![EntityTag::new(false, "xyzzy".to_string()),
EntityTag::new(false, "r2d2xxxx".to_string()),
EntityTag::new(false, "c3piozzzz".to_string())])));
test_header!(test3, vec![b"*"], Some(IfMatch::Any));
}
}