Skip to content

Commit 0953b26

Browse files
committed
Merge pull request #548 from winding-lines/connection-cov
test(connection): increasing test coverage of connection module
2 parents ac03b5e + c1a8e3b commit 0953b26

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/header/common/connection.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,23 @@ impl Connection {
8888
bench_header!(close, Connection, { vec![b"close".to_vec()] });
8989
bench_header!(keep_alive, Connection, { vec![b"keep-alive".to_vec()] });
9090
bench_header!(header, Connection, { vec![b"authorization".to_vec()] });
91+
92+
#[cfg(test)]
93+
mod tests {
94+
use super::{Connection,ConnectionHeader};
95+
use header::Header;
96+
use unicase::UniCase;
97+
98+
fn parse_option(header: Vec<u8>) -> Connection {
99+
let val = vec![header];
100+
let connection: Connection = Header::parse_header(&val[..]).unwrap();
101+
connection
102+
}
103+
104+
#[test]
105+
fn test_parse() {
106+
assert_eq!(Connection::close(),parse_option(b"close".to_vec()));
107+
assert_eq!(Connection::keep_alive(),parse_option(b"keep-alive".to_vec()));
108+
assert_eq!(Connection(vec![ConnectionHeader(UniCase("upgrade".to_owned()))]),parse_option(b"upgrade".to_vec()));
109+
}
110+
}

0 commit comments

Comments
 (0)