11using System ;
22using System . IO ;
3+ using System . Text ;
34using NUnit . Framework ;
45using UnityEngine . Rendering ;
56
@@ -23,7 +24,13 @@ partial class CoreUtilsTests
2324 [ TestCase ( "Assets/TestFolder/Folder#Test/SubFolder/" , TestName = "Folder name containing a hash character" ) ]
2425 [ TestCase ( "Assets/TestFolder/Folder@Test/SubFolder/File.txt" , TestName = "File name containing @ character" ) ]
2526 [ TestCase ( "Assets/TestFolder/Folder\\ SubFolder/File" , TestName = "File without extension" ) ]
26-
27+ [ TestCase ( "Assets/TestFolder//DoubleSlash/File.txt" , TestName = "Path with double slashes" ) ]
28+ [ TestCase ( "Assets/TestFolder///TripleSlash/File.txt" , TestName = "Path with triple slashes" ) ]
29+ [ TestCase ( "Assets/TestFolder/Mixed\\ Separators/File.txt" , TestName = "Mixed forward and backslashes" ) ]
30+ [ TestCase ( "Assets/TestFolder/A/B/C/D/E/F/G/H/I/J/Deep.txt" , TestName = "Deep nested path (10 levels)" ) ]
31+ [ TestCase ( "Assets/TestFolder/Unicode文件夹/File.txt" , TestName = "Unicode characters in folder name" ) ]
32+ [ TestCase ( "Assets/TestFolder/Émojis😀/File.txt" , TestName = "Emoji in folder name" ) ]
33+ [ TestCase ( "Assets/TestFolder/VeryLongFolderNameThatExceedsNormalLength123456789012345678901234567890/File.txt" , TestName = "Very long folder name" ) ]
2734 public void EnsureFolderTreeInAssetFilePath ( string path )
2835 {
2936 string folderPath = Path . GetDirectoryName ( path ) ;
@@ -34,15 +41,31 @@ public void EnsureFolderTreeInAssetFilePath(string path)
3441 [ Test ]
3542 [ TestCase ( "Assets" , TestName = "Just Assets and not Assets/" ) ]
3643 [ TestCase ( "NotAssetsFolder/TestFolder/" , TestName = "FilePath does not start with Assets/" ) ]
44+ [ TestCase ( "assets/TestFolder/" , TestName = "Lowercase assets (case sensitivity)" ) ]
45+ [ TestCase ( "ASSETS/TestFolder/" , TestName = "Uppercase ASSETS" ) ]
46+ [ TestCase ( "FileName.txt" , TestName = "FileName.txt" ) ]
47+ [ TestCase ( "C:\\ Filename.txt" , TestName = "C:\\ Filename.txt" ) ]
3748 public void EnsureFolderTreeInAssetFilePathThrows ( string folderPath )
3849 {
3950 Assert . Throws < ArgumentException > ( ( ) => CoreUtils . EnsureFolderTreeInAssetFilePath ( folderPath ) ) ;
4051 }
4152
53+ [ Test ]
54+ public void EnsureFolderTreeInAssetFilePath_NullOrEmpty_DoesNotThrow ( )
55+ {
56+ Assert . DoesNotThrow ( ( ) => CoreUtils . EnsureFolderTreeInAssetFilePath ( null ) ) ;
57+ Assert . DoesNotThrow ( ( ) => CoreUtils . EnsureFolderTreeInAssetFilePath ( "" ) ) ;
58+ Assert . DoesNotThrow ( ( ) => CoreUtils . EnsureFolderTreeInAssetFilePath ( string . Empty ) ) ;
59+ }
60+
4261 [ TearDown ]
4362 public void TearDown ( )
4463 {
45- AssetDatabase . DeleteAsset ( "Assets/TestFolder" ) ;
64+ if ( AssetDatabase . IsValidFolder ( "Assets/TestFolder" ) )
65+ {
66+ AssetDatabase . DeleteAsset ( "Assets/TestFolder" ) ;
67+ }
68+ AssetDatabase . Refresh ( ) ;
4669 }
4770 }
4871}
0 commit comments