Browse Source

unittests: fix utlstringtest for windows

pull/114/head
nillerusr 2 years ago
parent
commit
dd1dc186f9
  1. 25
      unittests/tier1test/utlstringtest.cpp

25
unittests/tier1test/utlstringtest.cpp

@ -180,6 +180,30 @@ static void FormatTests()
static void FileNameAPITests() 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 path( "/source2/game/source2/somefile.ext" );
CUtlString absPath = path.AbsPath(); CUtlString absPath = path.AbsPath();
@ -202,6 +226,7 @@ static void FileNameAPITests()
absPath = path.PathJoin( dir.Get(), file.Get() ); absPath = path.PathJoin( dir.Get(), file.Get() );
Shipping_Assert( !V_stricmp( absPath.Get(), "/source2/game/source2/somefile" ) ); Shipping_Assert( !V_stricmp( absPath.Get(), "/source2/game/source2/somefile" ) );
#endif
} }
DEFINE_TESTCASE( UtlStringTest, UtlStringTestSuite ) DEFINE_TESTCASE( UtlStringTest, UtlStringTestSuite )

Loading…
Cancel
Save