File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -324,3 +324,28 @@ impl From<Scheme2> for Scheme {
324
324
Scheme { inner : src }
325
325
}
326
326
}
327
+
328
+ #[ cfg( test) ]
329
+ mod test {
330
+ use super :: * ;
331
+
332
+ #[ test]
333
+ fn scheme_eq_to_str ( ) {
334
+ assert_eq ! ( & scheme( "http" ) , "http" ) ;
335
+ assert_eq ! ( & scheme( "https" ) , "https" ) ;
336
+ assert_eq ! ( & scheme( "ftp" ) , "ftp" ) ;
337
+ assert_eq ! ( & scheme( "my+funky+scheme" ) , "my+funky+scheme" ) ;
338
+ }
339
+
340
+ #[ test]
341
+ fn invalid_scheme_is_error ( ) {
342
+ Scheme :: try_from ( "my_funky_scheme" ) . expect_err ( "Unexpectly valid Scheme" ) ;
343
+
344
+ // Invalid UTF-8
345
+ Scheme :: try_from ( [ 0xC0 ] . as_ref ( ) ) . expect_err ( "Unexpectly valid Scheme" ) ;
346
+ }
347
+
348
+ fn scheme ( s : & str ) -> Scheme {
349
+ s. parse ( ) . expect ( & format ! ( "Invalid scheme: {}" , s) )
350
+ }
351
+ }
You can’t perform that action at this time.
0 commit comments