|
|
|
@ -180,6 +180,30 @@ static void FormatTests()
@@ -180,6 +180,30 @@ static void FormatTests()
|
|
|
|
|
|
|
|
|
|
static void FileNameAPITests() |
|
|
|
|
{ |
|
|
|
|
#ifdef WIN32 |
|
|
|
|
CUtlString path( "c:\\source2\\game\\source2\\somefile.ext" ); |
|
|
|
|
|
|
|
|
|
CUtlString absPath = path.AbsPath(); |
|
|
|
|
Shipping_Assert( absPath == path ); |
|
|
|
|
CUtlString file = path.UnqualifiedFilename(); |
|
|
|
|
Shipping_Assert( !V_stricmp( file.Get(), "somefile.ext" ) ); |
|
|
|
|
CUtlString dir = path.DirName(); |
|
|
|
|
Shipping_Assert( !V_stricmp( dir.Get(), "c:\\source2\\game\\source2" ) ); |
|
|
|
|
dir = dir.DirName(); |
|
|
|
|
Shipping_Assert( !V_stricmp( dir.Get(), "c:\\source2\\game" ) ); |
|
|
|
|
CUtlString baseName = path.StripExtension(); |
|
|
|
|
Shipping_Assert( !V_stricmp( baseName.Get(), "c:\\source2\\game\\source2\\somefile" ) ); |
|
|
|
|
dir = path.StripFilename(); |
|
|
|
|
Shipping_Assert( !V_stricmp( dir.Get(), "c:\\source2\\game\\source2" ) ); |
|
|
|
|
|
|
|
|
|
file = path.GetBaseFilename(); |
|
|
|
|
Shipping_Assert( !V_stricmp( file.Get(), "somefile" ) ); |
|
|
|
|
CUtlString ext = path.GetExtension(); |
|
|
|
|
Shipping_Assert( !V_stricmp( ext.Get(), "ext" ) ); |
|
|
|
|
|
|
|
|
|
absPath = path.PathJoin( dir.Get(), file.Get() ); |
|
|
|
|
Shipping_Assert( !V_stricmp( absPath.Get(), "c:\\source2\\game\\source2\\somefile" ) ); |
|
|
|
|
#else |
|
|
|
|
CUtlString path( "/source2/game/source2/somefile.ext" ); |
|
|
|
|
|
|
|
|
|
CUtlString absPath = path.AbsPath(); |
|
|
|
@ -202,6 +226,7 @@ static void FileNameAPITests()
@@ -202,6 +226,7 @@ static void FileNameAPITests()
|
|
|
|
|
|
|
|
|
|
absPath = path.PathJoin( dir.Get(), file.Get() ); |
|
|
|
|
Shipping_Assert( !V_stricmp( absPath.Get(), "/source2/game/source2/somefile" ) ); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
DEFINE_TESTCASE( UtlStringTest, UtlStringTestSuite ) |
|
|
|
|