@@ -1998,61 +1998,6 @@ fn test_non_ascii_unicode() {
19981998 assert_eq ! ( path. file_name( ) , Some ( OsStr :: new( "file.txt" ) ) ) ;
19991999}
20002000
2001-
2002- // Test: Reserved device names (Windows)
2003- // This test ensures that reserved device names like "CON", "PRN", etc., are handled as normal paths on non-Windows platforms,
2004- // and as special cases on Windows (if applicable).
2005- #[ test]
2006- #[ cfg( windows) ]
2007- fn test_reserved_device_names ( ) {
2008- for & name in & [ "CON" , "PRN" , "AUX" , "NUL" , "COM1" , "LPT1" ] {
2009- let path = Path :: new ( name) ;
2010- assert_eq ! ( path. file_name( ) , Some ( OsStr :: new( name) ) ) ;
2011- assert_eq ! ( path. extension( ) , None ) ;
2012- }
2013- }
2014-
2015- // Test: Trailing dots/spaces (Windows)
2016- // This test checks how Path handles trailing dots or spaces, which are special on Windows.
2017- // On Unix, these should be treated as normal characters.
2018- #[ test]
2019- #[ cfg( windows) ]
2020- fn test_trailing_dots_and_spaces ( ) {
2021- let path = Path :: new ( "foo. " ) ;
2022- assert_eq ! ( path. file_stem( ) , Some ( OsStr :: new( "foo" ) ) ) ;
2023- assert_eq ! ( path. extension( ) , Some ( OsStr :: new( " " ) ) ) ;
2024- assert_eq ! ( path. file_name( ) , Some ( OsStr :: new( "foo. " ) ) ) ;
2025- assert_eq ! ( path. to_str( ) , Some ( "foo. " ) ) ;
2026- let path = Path :: new ( "bar..." ) ;
2027- assert_eq ! ( path. file_stem( ) , Some ( OsStr :: new( "bar" ) ) ) ;
2028- assert_eq ! ( path. extension( ) , Some ( OsStr :: new( "..." ) ) ) ;
2029- assert_eq ! ( path. file_name( ) , Some ( OsStr :: new( "bar..." ) ) ) ;
2030- assert_eq ! ( path. to_str( ) , Some ( "bar..." ) ) ;
2031- }
2032-
2033- // Test: Only extension (e.g., ".gitignore")
2034- // This test verifies that files with only an extension and no base name are handled correctly.
2035- // It checks that the extension is recognized and the file stem is None or empty as appropriate.
2036- #[ test]
2037- fn test_only_extension ( ) {
2038- let path = Path :: new ( ".ext" ) ;
2039- assert_eq ! ( path. extension( ) , None ) ;
2040- assert_eq ! ( path. file_stem( ) , Some ( OsStr :: new( ".ext" ) ) ) ;
2041- assert_eq ! ( path. file_name( ) , Some ( OsStr :: new( ".ext" ) ) ) ;
2042- }
2043-
2044- // Test: Long components
2045- // This test checks that Path can handle very long path components without truncation or error.
2046- // It ensures that the length of the component is preserved.
2047- #[ test]
2048- fn test_long_component ( ) {
2049- let long = "a" . repeat ( 300 ) ;
2050- let path = Path :: new ( & long) ;
2051- assert_eq ! ( path. file_name( ) , Some ( OsStr :: new( & long) ) ) ;
2052- assert_eq ! ( path. to_str( ) , Some ( long. as_str( ) ) ) ;
2053- assert_eq ! ( path. iter( ) . count( ) , 1 ) ;
2054- }
2055-
20562001// Test: Embedded newlines
20572002// This test verifies that newlines within path components are preserved and do not break path parsing.
20582003// It ensures that Path treats newlines as normal characters.
0 commit comments