yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
7b570feed
master
1// unit-test-path.cpp 2 3#include "../../source/core/slang-io.h" 4#include "unit-test/slang-unit-test.h" 5 6using namespace Slang ; 7 8SLANG_UNIT_TEST (path ) 9{ 10#if SLANG_WINDOWS_FAMILY 11// Disable for now on non windows has some problems on *some* Linux based CI. 12 { 13String path ; 14SlangResult res = Path ::getCanonical ("source/slang" ,path ); 15SLANG_CHECK (SLANG_SUCCEEDED (res )); 16 17String parentPath ; 18res = Path ::getCanonical ("source" ,parentPath ); 19SLANG_CHECK (SLANG_SUCCEEDED (res )); 20 21String parentPath2 = Path ::getParentDirectory (path ); 22SLANG_CHECK (parentPath == parentPath2 ); 23 } 24#endif 25// Test the paths 26 { 27SLANG_CHECK (Path ::simplify ("." )== "." ); 28SLANG_CHECK (Path ::simplify (".." )== ".." ); 29SLANG_CHECK (Path ::simplify ("blah/.." )== "." ); 30 31SLANG_CHECK (Path ::simplify ("blah/.././a" )== "a" ); 32 33SLANG_CHECK (Path ::simplify ("a:/what/.././../is/./../this/." )== "a:/../this" ); 34 35SLANG_CHECK (Path ::simplify ("a:/what/.././../is/./../this/./" )== "a:/../this" ); 36 37SLANG_CHECK (Path ::simplify ("a:\\what\\..\\.\\..\\is\\.\\..\\this\\.\\" )== "a:/../this" ); 38 39SLANG_CHECK ( 40Path ::simplify ("tests/preprocessor/.\\pragma-once-a.h" )== 41"tests/preprocessor/pragma-once-a.h" ); 42 43 44SLANG_CHECK (Path ::hasRelativeElement ("." )); 45SLANG_CHECK (Path ::hasRelativeElement (".." )); 46SLANG_CHECK (Path ::hasRelativeElement ("blah/.." )); 47 48SLANG_CHECK (Path ::hasRelativeElement ("blah/.././a" )); 49SLANG_CHECK (Path ::hasRelativeElement ("a" )== false); 50SLANG_CHECK (Path ::hasRelativeElement ("blah/a" )== false); 51SLANG_CHECK (Path ::hasRelativeElement ("a:\\blah/a" )== false); 52 53 54SLANG_CHECK (Path ::hasRelativeElement ("a:/what/.././../is/./../this/." )); 55 56SLANG_CHECK (Path ::hasRelativeElement ("a:/what/.././../is/./../this/./" )); 57 58SLANG_CHECK (Path ::hasRelativeElement ("a:\\what\\..\\.\\..\\is\\.\\..\\this\\.\\" )); 59 } 60}