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.
|
// RTEMS errors are probably just a buildsys issue & this will change or go away.
|
||||||
// Redox will probably implement this in the future.
|
// 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)
|
#define SUPPORTS_DOUBLE_SLASH_PATH (IS_CYGWIN)
|
||||||
// POSIX standard says paths beginning with 2 slashes are "implementation defined"
|
// POSIX standard says paths beginning with 2 slashes are "implementation defined"
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "core/archive.h"
|
#include "core/archive.h"
|
||||||
#include "twtest/test.h"
|
#include "twtest/test.h"
|
||||||
#include "core/error.h"
|
#include "core/error.h"
|
||||||
|
#include "tw/twutil.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
TSS_EXCEPTION(eTestArchiveError, eError);
|
TSS_EXCEPTION(eTestArchiveError, eError);
|
||||||
|
@ -119,6 +120,12 @@ void TestLockedTemporaryArchive()
|
||||||
lockedArch.OpenReadWrite();
|
lockedArch.OpenReadWrite();
|
||||||
lockedArch.Close();
|
lockedArch.Close();
|
||||||
}
|
}
|
||||||
|
catch (eError& e)
|
||||||
|
{
|
||||||
|
threw=true;
|
||||||
|
TCERR << "Error opening locked temp archive" << std::endl;
|
||||||
|
cTWUtil::PrintErrorMsg(e);
|
||||||
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
threw = true;
|
threw = true;
|
||||||
|
@ -142,6 +149,12 @@ void TestLockedTemporaryArchive()
|
||||||
// this should delete the file
|
// this should delete the file
|
||||||
lockedArch.Close();
|
lockedArch.Close();
|
||||||
}
|
}
|
||||||
|
catch (eError& e)
|
||||||
|
{
|
||||||
|
threw=true;
|
||||||
|
TCERR << "Error writing locked temp archive" << std::endl;
|
||||||
|
cTWUtil::PrintErrorMsg(e);
|
||||||
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
threw = true;
|
threw = true;
|
||||||
|
@ -215,6 +228,6 @@ void TestFileArchive()
|
||||||
void RegisterSuite_Archive()
|
void RegisterSuite_Archive()
|
||||||
{
|
{
|
||||||
RegisterTest("Archive", "MemoryArchive", TestMemoryArchive);
|
RegisterTest("Archive", "MemoryArchive", TestMemoryArchive);
|
||||||
RegisterTest("Archive", "LockedTemporaryArchive)", TestLockedTemporaryArchive);
|
RegisterTest("Archive", "LockedTemporaryArchive", TestLockedTemporaryArchive);
|
||||||
RegisterTest("Archive", "FileArchive", TestFileArchive);
|
RegisterTest("Archive", "FileArchive", TestFileArchive);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,21 @@
|
||||||
#include "core/errorbucketimpl.h"
|
#include "core/errorbucketimpl.h"
|
||||||
#include "twtest/test.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)
|
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 ) )
|
while( cCharUtil::PopNextChar( cur, end, first, last ) )
|
||||||
{
|
{
|
||||||
int length = (int)(last - first);
|
int length = (int)(last - first);
|
||||||
|
if (length != length_expected )
|
||||||
|
TCERR << "CheckChars on '" << str << "' : expected = " << length_expected << " | observed = " << length << std::endl;
|
||||||
TEST(length == length_expected);
|
TEST(length == length_expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +80,11 @@ void TestCharUtilBasic()
|
||||||
{
|
{
|
||||||
CheckChars( "foo" );
|
CheckChars( "foo" );
|
||||||
CheckChars( "fo\x23 54" );
|
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()
|
void RegisterSuite_CharUtil()
|
||||||
|
|
|
@ -246,7 +246,7 @@ const TSTRING expected_os("Darwin");
|
||||||
#elif IS_CYGWIN
|
#elif IS_CYGWIN
|
||||||
const TSTRING expected_os("Cygwin");
|
const TSTRING expected_os("Cygwin");
|
||||||
#elif IS_DOS_DJGPP
|
#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
|
#elif IS_ANDROID
|
||||||
const TSTRING expected_os("Android");
|
const TSTRING expected_os("Android");
|
||||||
#elif IS_DRAGONFLYBSD
|
#elif IS_DRAGONFLYBSD
|
||||||
|
@ -308,6 +308,10 @@ void TestPlatformDetection()
|
||||||
TEST( uname(&os_info) == 0);
|
TEST( uname(&os_info) == 0);
|
||||||
|
|
||||||
TSTRING observed_os(os_info.sysname);
|
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 );
|
TEST( observed_os == expected_os );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ void TestTaskTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(!timer.IsRunning());
|
TEST(!timer.IsRunning());
|
||||||
TEST(5 >= timer.GetTotalTime());
|
TEST(5 <= timer.GetTotalTime());
|
||||||
TEST(5 == timer.GetNumTimesStarted());
|
TEST(5 == timer.GetNumTimesStarted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue