Tweak a couple of tests that generally fail due to environmental issues (locale configuration, local IP <--> hostname mapping, current username) so they're marked as skipped instead of failed when it looks like a configuration problem.

This commit is contained in:
Brian Cox 2017-09-08 18:04:35 -07:00
parent e7b00507e9
commit 041ca7f3b3
2 changed files with 44 additions and 33 deletions

View File

@ -89,41 +89,44 @@ void TestAtoi()
void TestItoa()
{
#if !IS_CYGWIN
//
// can't do ASSERT( str == _T("123456") )
// because locale may turn it into "123,465" or whatever
//
try
{
//
// can't do ASSERT( str == _T("123456") )
// because locale may turn it into "123,465" or whatever
//
//
// setup
//
int32 n = 123456;
TSTRING str;
//
// setup
//
int32 n = 123456;
TSTRING str;
//
// Try formatting with our default locale
//
cTWLocale::InitGlobalLocale();
cTWLocale::FormatNumber( n, str );
TEST( str == "123456" );
//
// Try formatting with our default locale
//
cTWLocale::InitGlobalLocale();
cTWLocale::FormatNumber( n, str );
TEST( str == "123456" );
//
// Try formatting with "" locale
//
std::locale::global( std::locale("") );
cTWLocale::FormatNumber( n, str );
TEST( str == "123,456" );
//
// Try formatting with "" locale
//
std::locale::global( std::locale("") );
cTWLocale::FormatNumber( n, str );
TEST( str == "123,456" );
//
// Try formatting with "C" locale
//
std::locale::global( std::locale("") );
cTWLocale::FormatNumber( n, str );
TEST( str == "123,456" );
#else
skip("Test disabled because Cygwin doesn't like the 'C' locale for some reason");
#endif
//
// Try formatting with "C" locale
//
std::locale::global( std::locale("") );
cTWLocale::FormatNumber( n, str );
TEST( str == "123,456" );
}
catch(const std::runtime_error& e)
{
skip("Skipping test due to configuration issue w/ 'C' locale");
}
}
/* We don't do atoi stuff in cTWLocale anymore, so no roundtrip

View File

@ -157,14 +157,22 @@ void TestGetCurrentUserName()
{
#if !IS_SKYOS // SkyOS breaks on this, for as-yet-unknown reasons
TSTRING username;
TEST( iFSServices::GetInstance()->GetCurrentUserName(username) )
bool success = iFSServices::GetInstance()->GetCurrentUserName(username);
if ( !success )
skip("GetCurrentUserName test skipped, usually caused by system configuration problems");
TEST("GetCurrentUserName() did not throw");
#endif
}
void TestGetIPAddress()
{
uint32 ipaddr;
TEST( iFSServices::GetInstance()->GetIPAddress( ipaddr ) );
bool success = iFSServices::GetInstance()->GetIPAddress( ipaddr );
if ( !success )
skip("GetIPAddress test skipped, usually caused by hostname/IP configuration problems");
TEST("GetIPAddress() did not throw");
}
void TestGetExecutableFilename()