mirror of https://github.com/fafhrd91/actix-web
test: add headermap iterator tests
confirmed new tests fail as expected
This commit is contained in:
parent
245b511dfd
commit
91882861ed
|
|
@ -1160,6 +1160,40 @@ mod tests {
|
||||||
assert!(vals.next().is_none());
|
assert!(vals.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn iter_len_counts_values() {
|
||||||
|
let mut map = HeaderMap::new();
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("a=1"));
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("b=2"));
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("c=3"));
|
||||||
|
|
||||||
|
assert_eq!(map.iter().count(), 3);
|
||||||
|
assert_eq!(map.iter().len(), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn into_iter_len_counts_values() {
|
||||||
|
let mut map = HeaderMap::new();
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("a=1"));
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("b=2"));
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("c=3"));
|
||||||
|
|
||||||
|
assert_eq!(map.clone().into_iter().count(), 3);
|
||||||
|
assert_eq!(map.into_iter().len(), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn drain_len_counts_values() {
|
||||||
|
let mut map = HeaderMap::new();
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("a=1"));
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("b=2"));
|
||||||
|
map.append(header::SET_COOKIE, HeaderValue::from_static("c=3"));
|
||||||
|
|
||||||
|
let mut drained = map.clone();
|
||||||
|
assert_eq!(map.drain().count(), 3);
|
||||||
|
assert_eq!(drained.drain().len(), 3);
|
||||||
|
}
|
||||||
|
|
||||||
fn owned_pair<'a>((name, val): (&'a HeaderName, &'a HeaderValue)) -> (HeaderName, HeaderValue) {
|
fn owned_pair<'a>((name, val): (&'a HeaderName, &'a HeaderValue)) -> (HeaderName, HeaderValue) {
|
||||||
(name.clone(), val.clone())
|
(name.clone(), val.clone())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue