Additional unit test tweaks to make DOS+DJGPP happier
This commit is contained in:
parent
9872bef2f2
commit
249c2cd33f
|
@ -335,7 +335,7 @@
|
|||
// RTEMS errors are probably just a buildsys issue & this will change or go away.
|
||||
// Redox will probably implement this in the future.
|
||||
|
||||
#define CAN_UNLINK_WHILE_OPEN (!IS_AROS && !IS_RISCOS && !IS_REDOX)
|
||||
#define CAN_UNLINK_WHILE_OPEN (!IS_AROS && !IS_RISCOS && !IS_REDOX && !IS_DOS_DJGPP)
|
||||
|
||||
#define SUPPORTS_DOUBLE_SLASH_PATH (IS_CYGWIN)
|
||||
// POSIX standard says paths beginning with 2 slashes are "implementation defined"
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "core/archive.h"
|
||||
#include "twtest/test.h"
|
||||
#include "core/error.h"
|
||||
#include "tw/twutil.h"
|
||||
#include <stdio.h>
|
||||
|
||||
TSS_EXCEPTION(eTestArchiveError, eError);
|
||||
|
@ -119,6 +120,12 @@ void TestLockedTemporaryArchive()
|
|||
lockedArch.OpenReadWrite();
|
||||
lockedArch.Close();
|
||||
}
|
||||
catch (eError& e)
|
||||
{
|
||||
threw=true;
|
||||
TCERR << "Error opening locked temp archive" << std::endl;
|
||||
cTWUtil::PrintErrorMsg(e);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
threw = true;
|
||||
|
@ -142,6 +149,12 @@ void TestLockedTemporaryArchive()
|
|||
// this should delete the file
|
||||
lockedArch.Close();
|
||||
}
|
||||
catch (eError& e)
|
||||
{
|
||||
threw=true;
|
||||
TCERR << "Error writing locked temp archive" << std::endl;
|
||||
cTWUtil::PrintErrorMsg(e);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
threw = true;
|
||||
|
@ -215,6 +228,6 @@ void TestFileArchive()
|
|||
void RegisterSuite_Archive()
|
||||
{
|
||||
RegisterTest("Archive", "MemoryArchive", TestMemoryArchive);
|
||||
RegisterTest("Archive", "LockedTemporaryArchive)", TestLockedTemporaryArchive);
|
||||
RegisterTest("Archive", "LockedTemporaryArchive", TestLockedTemporaryArchive);
|
||||
RegisterTest("Archive", "FileArchive", TestFileArchive);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,21 @@
|
|||
#include "core/errorbucketimpl.h"
|
||||
#include "twtest/test.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
bool localeIsUtf8()
|
||||
{
|
||||
std::string locale(setlocale(LC_CTYPE, 0));
|
||||
std::transform(locale.begin(), locale.end(), locale.begin(), ::tolower);
|
||||
|
||||
if(locale.find("utf-8") != std::string::npos)
|
||||
return true;
|
||||
|
||||
if(locale.find("utf8") != std::string::npos)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CheckChars( const TSTRING& str, int length_expected = 1)
|
||||
{
|
||||
|
@ -52,6 +67,8 @@ void CheckChars( const TSTRING& str, int length_expected = 1)
|
|||
while( cCharUtil::PopNextChar( cur, end, first, last ) )
|
||||
{
|
||||
int length = (int)(last - first);
|
||||
if (length != length_expected )
|
||||
TCERR << "CheckChars on '" << str << "' : expected = " << length_expected << " | observed = " << length << std::endl;
|
||||
TEST(length == length_expected);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +80,11 @@ void TestCharUtilBasic()
|
|||
{
|
||||
CheckChars( "foo" );
|
||||
CheckChars( "fo\x23 54" );
|
||||
CheckChars( "\U0001F408", 4 ); //Cat emoji. Assumes UTF-8
|
||||
|
||||
if(localeIsUtf8())
|
||||
CheckChars( "\U0001F408", 4 ); //Cat emoji, if UTF-8
|
||||
else
|
||||
CheckChars( "\U0001F408", 1 ); // just a bag of bytes otherwise
|
||||
}
|
||||
|
||||
void RegisterSuite_CharUtil()
|
||||
|
|
|
@ -246,7 +246,7 @@ const TSTRING expected_os("Darwin");
|
|||
#elif IS_CYGWIN
|
||||
const TSTRING expected_os("Cygwin");
|
||||
#elif IS_DOS_DJGPP
|
||||
const TSTRING expected_os("DJGPP");
|
||||
const TSTRING expected_os("FreeDOS"); // This will likely fail for other DOS flavors
|
||||
#elif IS_ANDROID
|
||||
const TSTRING expected_os("Android");
|
||||
#elif IS_DRAGONFLYBSD
|
||||
|
@ -308,6 +308,10 @@ void TestPlatformDetection()
|
|||
TEST( uname(&os_info) == 0);
|
||||
|
||||
TSTRING observed_os(os_info.sysname);
|
||||
|
||||
if ( observed_os != expected_os )
|
||||
TCERR << "Expected OS: " << expected_os << " | Observed OS: " << observed_os << std::endl;
|
||||
|
||||
TEST( observed_os == expected_os );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void TestTaskTimer()
|
|||
}
|
||||
|
||||
TEST(!timer.IsRunning());
|
||||
TEST(5 >= timer.GetTotalTime());
|
||||
TEST(5 <= timer.GetTotalTime());
|
||||
TEST(5 == timer.GetNumTimesStarted());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue