File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -835,3 +835,36 @@ impl<T> DerefMut for GlobalWriteGuard<T> {
835835 self . globals
836836 }
837837}
838+
839+ #[ cfg( feature = "embed" ) ]
840+ #[ cfg( test) ]
841+ mod embed_tests {
842+ use crate :: embed:: Embed ;
843+ use std:: os:: raw:: c_char;
844+
845+ use super :: SapiHeader ;
846+
847+ #[ test]
848+ fn test_sapi_header ( ) {
849+ Embed :: run ( || {
850+ let headers = [
851+ ( "Content-Type: text/html" , "Content-Type" , "text/html" ) ,
852+ ( "X: Custom:Header" , "X" , "Custom:Header" ) ,
853+ ] ;
854+
855+ for ( header_text, name, value) in headers {
856+ let header = SapiHeader {
857+ header : header_text. as_bytes ( ) . as_ptr ( ) as * mut c_char ,
858+ header_len : header_text. len ( ) ,
859+ } ;
860+ assert_eq ! ( header. name( ) , name, "Header name mismatch" ) ;
861+ assert_eq ! ( header. value( ) , Some ( value) , "Header value mismatch" ) ;
862+ assert_eq ! (
863+ header. as_str( ) ,
864+ format!( "{name}: {value}" ) ,
865+ "Header string mismatch"
866+ ) ;
867+ }
868+ } ) ;
869+ }
870+ }
You can’t perform that action at this time.
0 commit comments