File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -88,3 +88,23 @@ impl Connection {
8888bench_header ! ( close, Connection , { vec![ b"close" . to_vec( ) ] } ) ;
8989bench_header ! ( keep_alive, Connection , { vec![ b"keep-alive" . to_vec( ) ] } ) ;
9090bench_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+ }
You can’t perform that action at this time.
0 commit comments