more tests

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@6989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-03-30 00:15:31 +00:00
parent 45680bc875
commit ee5bb015fe

View File

@@ -39,13 +39,14 @@
//#define TEST_CMDLINE //#define TEST_CMDLINE
//#define TEST_DATETIME //#define TEST_DATETIME
//#define TEST_DIR //#define TEST_DIR
#define TEST_DLLLOADER
//#define TEST_EXECUTE //#define TEST_EXECUTE
//#define TEST_FILECONF //#define TEST_FILECONF
//#define TEST_HASH //#define TEST_HASH
//#define TEST_LOG //#define TEST_LOG
//#define TEST_LONGLONG //#define TEST_LONGLONG
//#define TEST_MIME //#define TEST_MIME
#define TEST_INFO_FUNCTIONS //#define TEST_INFO_FUNCTIONS
//#define TEST_SOCKETS //#define TEST_SOCKETS
//#define TEST_STRINGS //#define TEST_STRINGS
//#define TEST_THREADS //#define TEST_THREADS
@@ -191,6 +192,60 @@ static void TestDirEnum()
#endif // TEST_DIR #endif // TEST_DIR
// ----------------------------------------------------------------------------
// wxDllLoader
// ----------------------------------------------------------------------------
#ifdef TEST_DLLLOADER
#include <wx/dynlib.h>
static void TestDllLoad()
{
#if defined(__WXMSW__)
static const wxChar *LIB_NAME = _T("kernel32.dll");
static const wxChar *FUNC_NAME = _T("lstrlenA");
#elif defined(__UNIX__)
static const wxChar *LIB_NAME = _T("libc.so");
static const wxChar *FUNC_NAME = _T("strlen");
#else
#error "don't know how to test wxDllLoader on this platform"
#endif
puts("*** testing wxDllLoader ***\n");
wxDllType dllHandle = wxDllLoader::LoadLibrary(LIB_NAME);
if ( !dllHandle )
{
wxPrintf(_T("ERROR: failed to load '%s'.\n"), LIB_NAME);
}
else
{
typedef int (*strlenType)(char *);
strlenType pfnStrlen = (strlenType)wxDllLoader::GetSymbol(dllHandle, FUNC_NAME);
if ( !pfnStrlen )
{
wxPrintf(_T("ERROR: function '%s' wasn't found in '%s'.\n"),
FUNC_NAME, LIB_NAME);
}
else
{
if ( pfnStrlen("foo") != 3 )
{
wxPrintf(_T("ERROR: loaded function is not strlen()!\n"));
}
else
{
puts("... ok");
}
}
wxDllLoader::UnloadLibrary(dllHandle);
}
}
#endif // TEST_DLLLOADER
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxExecute // wxExecute
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1830,17 +1885,20 @@ static void TestTimeArithmetics()
{ {
puts("\n*** testing arithmetic operations on wxDateTime ***"); puts("\n*** testing arithmetic operations on wxDateTime ***");
static const struct static const struct ArithmData
{ {
ArithmData(const wxDateSpan& sp, const char *nam)
: span(sp), name(nam) { }
wxDateSpan span; wxDateSpan span;
const char *name; const char *name;
} testArithmData[] = } testArithmData[] =
{ {
{ wxDateSpan::Day(), "day" }, ArithmData(wxDateSpan::Day(), "day"),
{ wxDateSpan::Week(), "week" }, ArithmData(wxDateSpan::Week(), "week"),
{ wxDateSpan::Month(), "month" }, ArithmData(wxDateSpan::Month(), "month"),
{ wxDateSpan::Year(), "year" }, ArithmData(wxDateSpan::Year(), "year"),
{ wxDateSpan(1, 2, 3, 4), "year, 2 months, 3 weeks, 4 days" }, ArithmData(wxDateSpan(1, 2, 3, 4), "year, 2 months, 3 weeks, 4 days"),
}; };
wxDateTime dt(29, wxDateTime::Dec, 1999), dt1, dt2; wxDateTime dt(29, wxDateTime::Dec, 1999), dt1, dt2;
@@ -2589,6 +2647,10 @@ int main(int argc, char **argv)
TestDirEnum(); TestDirEnum();
#endif // TEST_DIR #endif // TEST_DIR
#ifdef TEST_DLLLOADER
TestDllLoad();
#endif // TEST_DLLLOADER
#ifdef TEST_EXECUTE #ifdef TEST_EXECUTE
TestExecute(); TestExecute();
#endif // TEST_EXECUTE #endif // TEST_EXECUTE
@@ -2696,8 +2758,8 @@ int main(int argc, char **argv)
TestTimeParse(); TestTimeParse();
TestTimeFormat(); TestTimeFormat();
TestTimeArithmetics(); TestTimeArithmetics();
TestTimeHolidays();
} }
TestTimeHolidays();
if ( 0 ) if ( 0 )
TestInteractive(); TestInteractive();
#endif // TEST_DATETIME #endif // TEST_DATETIME
@@ -2706,3 +2768,4 @@ int main(int argc, char **argv)
return 0; return 0;
} }