@@ -31,16 +31,6 @@ fn test_parse_next_component() {
3131 parse_next_component( OsStr :: new( r"servershare" ) , false ) ,
3232 ( OsStr :: new( r"servershare" ) , OsStr :: new( "" ) )
3333 ) ;
34-
35- assert_eq ! (
36- parse_next_component( OsStr :: new( r"server/\//\/\\\\/////\/share" ) , false ) ,
37- ( OsStr :: new( r"server" ) , OsStr :: new( r"share" ) )
38- ) ;
39-
40- assert_eq ! (
41- parse_next_component( OsStr :: new( r"server\\\\\\\\\\\\\\share" ) , true ) ,
42- ( OsStr :: new( r"server" ) , OsStr :: new( r"\\\\\\\\\\\\\share" ) )
43- ) ;
4434}
4535
4636#[ test]
@@ -126,3 +116,22 @@ fn test_windows_prefix_components() {
126116 assert_eq ! ( drive. as_os_str( ) , OsStr :: new( "C:" ) ) ;
127117 assert_eq ! ( components. as_path( ) , Path :: new( "" ) ) ;
128118}
119+
120+ /// See #101358.
121+ ///
122+ /// Note that the exact behaviour here may change in the future.
123+ /// In which case this test will need to adjusted.
124+ #[ test]
125+ fn broken_unc_path ( ) {
126+ use crate :: path:: Component ;
127+
128+ let mut components = Path :: new ( r"\\foo\\bar\\" ) . components ( ) ;
129+ assert_eq ! ( components. next( ) , Some ( Component :: RootDir ) ) ;
130+ assert_eq ! ( components. next( ) , Some ( Component :: Normal ( "foo" . as_ref( ) ) ) ) ;
131+ assert_eq ! ( components. next( ) , Some ( Component :: Normal ( "bar" . as_ref( ) ) ) ) ;
132+
133+ let mut components = Path :: new ( "//foo//bar//" ) . components ( ) ;
134+ assert_eq ! ( components. next( ) , Some ( Component :: RootDir ) ) ;
135+ assert_eq ! ( components. next( ) , Some ( Component :: Normal ( "foo" . as_ref( ) ) ) ) ;
136+ assert_eq ! ( components. next( ) , Some ( Component :: Normal ( "bar" . as_ref( ) ) ) ) ;
137+ }
0 commit comments