mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge
This commit is contained in:
commit
54d3af930c
2360
contrib/libpoco/CHANGELOG
Normal file
2360
contrib/libpoco/CHANGELOG
Normal file
File diff suppressed because it is too large
Load Diff
53
contrib/libpoco/CONTRIBUTORS
Normal file
53
contrib/libpoco/CONTRIBUTORS
Normal file
@ -0,0 +1,53 @@
|
||||
Guenter Obiltschnig
|
||||
Alex Fabijanic
|
||||
Peter Schojer
|
||||
Ferdinand Beyer
|
||||
Krzysztof Burghardt
|
||||
Claus Dabringer
|
||||
Caleb Epstein
|
||||
Eran Hammer-Lahav
|
||||
Chris Johnson
|
||||
Sergey Kholodilov
|
||||
Ryan Kraay
|
||||
Larry Lewis
|
||||
Andrew J. P. Maclean
|
||||
Andrew Marlow
|
||||
Paschal Mushubi
|
||||
Jiang Shan
|
||||
David Shawley
|
||||
Sergey Skorokhodov
|
||||
Tom Tan
|
||||
Sergey N. Yatskevich
|
||||
Marc Chevrier
|
||||
Philippe Cuvillier
|
||||
Marian Krivos
|
||||
Franky Braem
|
||||
Philip Prindeville
|
||||
Anton Yabchinskiy
|
||||
Rangel Reale
|
||||
Fabrizio Duhem
|
||||
Patrick White
|
||||
Mike Naquin
|
||||
Roger Meier
|
||||
Mathaus Mendel
|
||||
Arturo Castro
|
||||
Adrian Imboden
|
||||
Matej Knopp
|
||||
Patrice Tarabbia
|
||||
Lucas Clemente
|
||||
Karl Reid
|
||||
Pascal Bach
|
||||
Cristian Thiago Moecke
|
||||
Sergei Nikulov
|
||||
Aaron Kaluszka
|
||||
Iyed Bennour
|
||||
Scott Davis
|
||||
Kristin Cowalcijk
|
||||
Yuval Kashtan
|
||||
Christopher Baker
|
||||
Scott Davis
|
||||
Jeff Adams
|
||||
Martin Osborne
|
||||
Björn Schramke
|
||||
--
|
||||
$Id$
|
@ -0,0 +1,77 @@
|
||||
//
|
||||
// WinTestRunner.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/include/WinTestRunner/WinTestRunner.h#1 $
|
||||
//
|
||||
// Application shell for CppUnit's TestRunner dialog.
|
||||
//
|
||||
|
||||
|
||||
#ifndef WinTestRunner_H_INCLUDED
|
||||
#define WinTestRunner_H_INCLUDED
|
||||
|
||||
|
||||
#if !defined(POCO_STATIC)
|
||||
#if defined(WinTestRunner_EXPORTS)
|
||||
#define WinTestRunner_API __declspec(dllexport)
|
||||
#else
|
||||
#define WinTestRunner_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define WinTestRunner_API
|
||||
#endif
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <vector>
|
||||
#include <afxwin.h>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
|
||||
class WinTestRunner_API WinTestRunner
|
||||
{
|
||||
public:
|
||||
WinTestRunner();
|
||||
~WinTestRunner();
|
||||
|
||||
void run();
|
||||
void addTest(Test* pTest);
|
||||
|
||||
private:
|
||||
std::vector<Test*> _tests;
|
||||
};
|
||||
|
||||
|
||||
class WinTestRunner_API WinTestRunnerApp: public CWinApp
|
||||
/// A simple application class that hosts the TestRunner dialog.
|
||||
/// Create a subclass and override the TestMain() method.
|
||||
///
|
||||
/// WinTestRunnerApp supports a batch mode, which runs the
|
||||
/// test using the standard text-based TestRunner from CppUnit.
|
||||
/// To enable batch mode, start the application with the "/b"
|
||||
/// or "/B" argument. Optionally, a filename may be specified
|
||||
/// where the test output will be written to: "/b:<path>" or
|
||||
/// "/B:<path>".
|
||||
///
|
||||
/// When run in batch mode, the exit code of the application
|
||||
/// will denote test success (0) or failure (1).
|
||||
{
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
virtual void TestMain() = 0;
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // WinTestRunner_H_INCLUDED
|
||||
|
27
contrib/libpoco/CppUnit/WinTestRunner/res/Resource.h
Normal file
27
contrib/libpoco/CppUnit/WinTestRunner/res/Resource.h
Normal file
@ -0,0 +1,27 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by TestRunner.rc
|
||||
//
|
||||
#define IDD_DIALOG_TESTRUNNER 129
|
||||
#define IDC_LIST 1000
|
||||
#define ID_RUN 1001
|
||||
#define ID_STOP 1002
|
||||
#define IDC_PROGRESS 1003
|
||||
#define IDC_INDICATOR 1004
|
||||
#define IDC_COMBO_TEST 1005
|
||||
#define IDC_STATIC_RUNS 1007
|
||||
#define IDC_STATIC_ERRORS 1008
|
||||
#define IDC_STATIC_FAILURES 1009
|
||||
#define IDC_EDIT_TIME 1010
|
||||
#define IDC_CHK_AUTORUN 1013
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 131
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1014
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
175
contrib/libpoco/CppUnit/WinTestRunner/res/WinTestRunner.rc
Normal file
175
contrib/libpoco/CppUnit/WinTestRunner/res/WinTestRunner.rc
Normal file
@ -0,0 +1,175 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""..\\res\\WinTestRunner.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "CppUnit WinTestRunner DLL"
|
||||
VALUE "FileVersion", "1, 0, 0, 1"
|
||||
VALUE "InternalName", "WinTestRunner"
|
||||
VALUE "LegalCopyright", "Copyright (c) 2005"
|
||||
VALUE "OriginalFilename", "TestRunner.dll"
|
||||
VALUE "ProductName", "CppUnit WinTestRunner Dynamic Link Library"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_DIALOG_TESTRUNNER DIALOGEX 0, 0, 512, 300
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "CppUnit WinTestRunner"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
COMBOBOX IDC_COMBO_TEST,7,20,424,273,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "Run",ID_RUN,455,7,50,14
|
||||
DEFPUSHBUTTON "Stop",ID_STOP,455,24,50,14
|
||||
CONTROL "List1",IDC_LIST,"SysListView32",LVS_REPORT | WS_BORDER |
|
||||
WS_TABSTOP,7,110,498,160
|
||||
PUSHBUTTON "Close",IDOK,455,279,50,14
|
||||
LTEXT "Test Name:",IDC_STATIC,7,9,179,9
|
||||
LTEXT "Progress:",IDC_STATIC,7,55,49,9
|
||||
LTEXT "Errors and Failures:",IDC_STATIC,7,99,67,9
|
||||
LTEXT "Runs:",IDC_STATIC,457,54,26,10
|
||||
LTEXT "Failures:",IDC_STATIC,457,80,26,10
|
||||
LTEXT "Errors:",IDC_STATIC,457,67,26,10
|
||||
RTEXT "0",IDC_STATIC_RUNS,487,54,16,10
|
||||
RTEXT "0",IDC_STATIC_ERRORS,487,67,16,10
|
||||
RTEXT "0",IDC_STATIC_FAILURES,487,80,16,10
|
||||
EDITTEXT IDC_EDIT_TIME,7,281,440,12,ES_AUTOHSCROLL | ES_READONLY |
|
||||
NOT WS_BORDER
|
||||
LTEXT "",IDC_PROGRESS,7,67,424,20,SS_SUNKEN | NOT WS_VISIBLE
|
||||
CONTROL "Auto Run",IDC_CHK_AUTORUN,"Button",BS_AUTOCHECKBOX |
|
||||
BS_LEFTTEXT | WS_TABSTOP,383,38,46,10
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_DIALOG_TESTRUNNER, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 505
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 293
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
44
contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.cpp
Normal file
44
contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// ActiveTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ActiveTest.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include <afxwin.h>
|
||||
#include "ActiveTest.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Spawn a thread to a test
|
||||
void ActiveTest::run(TestResult* result)
|
||||
{
|
||||
CWinThread* thread;
|
||||
|
||||
setTestResult(result);
|
||||
_runCompleted.ResetEvent();
|
||||
|
||||
thread = AfxBeginThread(threadFunction, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
|
||||
DuplicateHandle(GetCurrentProcess(), thread->m_hThread, GetCurrentProcess(), &_threadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS);
|
||||
|
||||
thread->ResumeThread();
|
||||
}
|
||||
|
||||
|
||||
// Simple execution thread. Assuming that an ActiveTest instance
|
||||
// only creates one of these at a time.
|
||||
UINT ActiveTest::threadFunction(LPVOID thisInstance)
|
||||
{
|
||||
ActiveTest* test = (ActiveTest*) thisInstance;
|
||||
|
||||
test->run();
|
||||
test->_runCompleted.SetEvent();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
89
contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.h
Normal file
89
contrib/libpoco/CppUnit/WinTestRunner/src/ActiveTest.h
Normal file
@ -0,0 +1,89 @@
|
||||
//
|
||||
// ActiveTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ActiveTest.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef ActiveTest_INCLUDED
|
||||
#define ActiveTest_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
#include <afxmt.h>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
/* A Microsoft-specific active test
|
||||
*
|
||||
* An active test manages its own
|
||||
* thread of execution. This one
|
||||
* is very simple and only sufficient
|
||||
* for the limited use we put it through
|
||||
* in the TestRunner. It spawns a thread
|
||||
* on run (TestResult *) and signals
|
||||
* completion of the test.
|
||||
*
|
||||
* We assume that only one thread
|
||||
* will be active at once for each
|
||||
* instance.
|
||||
*
|
||||
*/
|
||||
class ActiveTest: public TestDecorator
|
||||
{
|
||||
public:
|
||||
ActiveTest(Test* test);
|
||||
~ActiveTest();
|
||||
|
||||
void run(TestResult* result);
|
||||
|
||||
protected:
|
||||
HANDLE _threadHandle;
|
||||
CEvent _runCompleted;
|
||||
TestResult* _currentTestResult;
|
||||
|
||||
void run ();
|
||||
void setTestResult(TestResult* result);
|
||||
static UINT threadFunction(LPVOID thisInstance);
|
||||
};
|
||||
|
||||
|
||||
// Construct the active test
|
||||
inline ActiveTest::ActiveTest(Test *test): TestDecorator(test)
|
||||
{
|
||||
_currentTestResult = NULL;
|
||||
_threadHandle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
|
||||
// Pend until the test has completed
|
||||
inline ActiveTest::~ActiveTest()
|
||||
{
|
||||
CSingleLock(&_runCompleted, TRUE);
|
||||
CloseHandle(_threadHandle);
|
||||
}
|
||||
|
||||
|
||||
// Set the test result that we are to run
|
||||
inline void ActiveTest::setTestResult(TestResult* result)
|
||||
{
|
||||
_currentTestResult = result;
|
||||
}
|
||||
|
||||
|
||||
// Run our test result
|
||||
inline void ActiveTest::run()
|
||||
{
|
||||
TestDecorator::run(_currentTestResult);
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // ActiveTest_INCLUDED
|
||||
|
||||
|
50
contrib/libpoco/CppUnit/WinTestRunner/src/DLLMain.cpp
Normal file
50
contrib/libpoco/CppUnit/WinTestRunner/src/DLLMain.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// DLLMain.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/DLLMain.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include <afxwin.h>
|
||||
#include <afxdllx.h>
|
||||
|
||||
|
||||
static AFX_EXTENSION_MODULE TestRunnerDLL = { NULL, NULL };
|
||||
|
||||
|
||||
extern "C" int APIENTRY
|
||||
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
// Remove this if you use lpReserved
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
TRACE0("WinTestRunner.DLL Initializing\n");
|
||||
|
||||
// Extension DLL one-time initialization
|
||||
if (!AfxInitExtensionModule(TestRunnerDLL, hInstance))
|
||||
return 0;
|
||||
|
||||
// Insert this DLL into the resource chain
|
||||
// NOTE: If this Extension DLL is being implicitly linked to by
|
||||
// an MFC Regular DLL (such as an ActiveX Control)
|
||||
// instead of an MFC application, then you will want to
|
||||
// remove this line from DllMain and put it in a separate
|
||||
// function exported from this Extension DLL. The Regular DLL
|
||||
// that uses this Extension DLL should then explicitly call that
|
||||
// function to initialize this Extension DLL. Otherwise,
|
||||
// the CDynLinkLibrary object will not be attached to the
|
||||
// Regular DLL's resource chain, and serious problems will
|
||||
// result.
|
||||
|
||||
new CDynLinkLibrary(TestRunnerDLL);
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
TRACE0("WinTestRunner.DLL Terminating\n");
|
||||
// Terminate the library before destructors are called
|
||||
AfxTermExtensionModule(TestRunnerDLL);
|
||||
}
|
||||
return 1; // ok
|
||||
}
|
52
contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.cpp
Normal file
52
contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// GUITestResult.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/GUITestResult.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "TestRunnerDlg.h"
|
||||
#include "GUITestResult.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
void GUITestResult::addError(Test *test, CppUnitException *e)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
|
||||
TestResult::addError(test, e);
|
||||
_runner->addError(this, test, e);
|
||||
}
|
||||
|
||||
|
||||
void GUITestResult::addFailure(Test *test, CppUnitException *e)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
|
||||
TestResult::addFailure(test, e);
|
||||
_runner->addFailure(this, test, e);
|
||||
}
|
||||
|
||||
|
||||
void GUITestResult::startTest(Test *test)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
|
||||
TestResult::startTest(test);
|
||||
_runner->startTest(test);
|
||||
}
|
||||
|
||||
|
||||
void GUITestResult::endTest(Test *test)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
|
||||
TestResult::endTest(test);
|
||||
_runner->endTest(this, test);
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
83
contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.h
Normal file
83
contrib/libpoco/CppUnit/WinTestRunner/src/GUITestResult.h
Normal file
@ -0,0 +1,83 @@
|
||||
//
|
||||
// GUITestResult.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/GUITestResult.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef GuiTestResult_INCLUDED
|
||||
#define GuiTestResult_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/TestResult.h"
|
||||
#include <afxmt.h>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestRunnerDlg;
|
||||
|
||||
|
||||
class GUITestResult: public TestResult
|
||||
{
|
||||
public:
|
||||
GUITestResult(TestRunnerDlg* runner);
|
||||
~GUITestResult();
|
||||
|
||||
void addError(Test* test, CppUnitException* e);
|
||||
void addFailure(Test* test, CppUnitException* e);
|
||||
|
||||
void startTest(Test* test);
|
||||
void endTest(Test* test);
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
class LightweightSynchronizationObject: public TestResult::SynchronizationObject
|
||||
{
|
||||
public:
|
||||
void lock()
|
||||
{
|
||||
_syncObject.Lock();
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
_syncObject.Unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
CCriticalSection _syncObject;
|
||||
};
|
||||
|
||||
private:
|
||||
TestRunnerDlg *_runner;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Construct with lightweight synchronization
|
||||
inline GUITestResult::GUITestResult(TestRunnerDlg* runner): _runner(runner)
|
||||
{
|
||||
setSynchronizationObject(new LightweightSynchronizationObject());
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
inline GUITestResult::~GUITestResult()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Override without protection to prevent deadlock
|
||||
inline void GUITestResult::stop()
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // GuiTestResult_INCLUDED
|
140
contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.cpp
Normal file
140
contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
//
|
||||
// ProgressBar.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ProgressBar.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "ProgressBar.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Paint the progress bar in response to a paint message
|
||||
void ProgressBar::paint(CDC& dc)
|
||||
{
|
||||
paintBackground (dc);
|
||||
paintStatus (dc);
|
||||
}
|
||||
|
||||
|
||||
// Paint the background of the progress bar region
|
||||
void ProgressBar::paintBackground (CDC& dc)
|
||||
{
|
||||
CBrush brshBackground;
|
||||
CPen penGray (PS_SOLID, 1, RGB (128, 128, 128));
|
||||
CPen penWhite (PS_SOLID, 1, RGB (255, 255, 255));
|
||||
|
||||
VERIFY (brshBackground.CreateSolidBrush (::GetSysColor (COLOR_BTNFACE)));
|
||||
|
||||
dc.FillRect (_bounds, &brshBackground);
|
||||
|
||||
CPen *pOldPen;
|
||||
|
||||
pOldPen = dc.SelectObject (&penGray);
|
||||
{
|
||||
dc.MoveTo (_bounds.left, _bounds.top);
|
||||
dc.LineTo (_bounds.left + _bounds.Width () -1, _bounds.top);
|
||||
|
||||
dc.MoveTo (_bounds.left, _bounds.top);
|
||||
dc.LineTo (_bounds.left, _bounds.top + _bounds.Height () -1);
|
||||
|
||||
}
|
||||
dc.SelectObject (&penWhite);
|
||||
{
|
||||
dc.MoveTo (_bounds.left + _bounds.Width () -1, _bounds.top);
|
||||
dc.LineTo (_bounds.left + _bounds.Width () -1, _bounds.top + _bounds.Height () -1);
|
||||
|
||||
dc.MoveTo (_bounds.left, _bounds.top + _bounds.Height () -1);
|
||||
dc.LineTo (_bounds.left + _bounds.Width () -1, _bounds.top + _bounds.Height () -1);
|
||||
|
||||
}
|
||||
dc.SelectObject (pOldPen);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Paint the actual status of the progress bar
|
||||
void ProgressBar::paintStatus (CDC& dc)
|
||||
{
|
||||
if (_progress <= 0)
|
||||
return;
|
||||
|
||||
CBrush brshStatus;
|
||||
CRect rect (_bounds.left, _bounds.top,
|
||||
_bounds.left + _progressX, _bounds.bottom);
|
||||
|
||||
COLORREF statusColor = getStatusColor ();
|
||||
|
||||
VERIFY (brshStatus.CreateSolidBrush (statusColor));
|
||||
|
||||
rect.DeflateRect (1, 1);
|
||||
dc.FillRect (rect, &brshStatus);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Paint the current step
|
||||
void ProgressBar::paintStep (int startX, int endX)
|
||||
{
|
||||
// kludge: painting the whole region on each step
|
||||
_baseWindow->RedrawWindow (_bounds);
|
||||
_baseWindow->UpdateWindow ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Setup the progress bar for execution over a total number of steps
|
||||
void ProgressBar::start (int total)
|
||||
{
|
||||
_total = total;
|
||||
reset ();
|
||||
}
|
||||
|
||||
|
||||
// Take one step, indicating whether it was a successful step
|
||||
void ProgressBar::step (bool successful)
|
||||
{
|
||||
_progress++;
|
||||
|
||||
int x = _progressX;
|
||||
|
||||
_progressX = scale (_progress);
|
||||
|
||||
if (!_error && !successful)
|
||||
{
|
||||
_error = true;
|
||||
x = 1;
|
||||
}
|
||||
|
||||
paintStep (x, _progressX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Map from steps to display units
|
||||
int ProgressBar::scale (int value)
|
||||
{
|
||||
if (_total > 0)
|
||||
return max (1, value * (_bounds.Width () - 1) / _total);
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Reset the progress bar
|
||||
void ProgressBar::reset ()
|
||||
{
|
||||
_progressX = 1;
|
||||
_progress = 0;
|
||||
_error = false;
|
||||
|
||||
_baseWindow->RedrawWindow (_bounds);
|
||||
_baseWindow->UpdateWindow ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
74
contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.h
Normal file
74
contrib/libpoco/CppUnit/WinTestRunner/src/ProgressBar.h
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// ProgressBar.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/ProgressBar.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef ProgressBar_INCLUDED
|
||||
#define ProgressBar_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <afxwin.h>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
/* A Simple ProgressBar for test execution display
|
||||
*/
|
||||
class ProgressBar
|
||||
{
|
||||
public:
|
||||
ProgressBar(CWnd* baseWindow, CRect& bounds);
|
||||
|
||||
void step(bool successful);
|
||||
void paint(CDC& dc);
|
||||
int scale(int value);
|
||||
void reset();
|
||||
void start(int total);
|
||||
|
||||
protected:
|
||||
void paintBackground(CDC& dc);
|
||||
void paintStatus(CDC& dc);
|
||||
COLORREF getStatusColor();
|
||||
void paintStep(int startX, int endX);
|
||||
|
||||
CWnd* _baseWindow;
|
||||
CRect _bounds;
|
||||
|
||||
bool _error;
|
||||
int _total;
|
||||
int _progress;
|
||||
int _progressX;
|
||||
};
|
||||
|
||||
|
||||
// Construct a ProgressBar
|
||||
inline ProgressBar::ProgressBar(CWnd* baseWindow, CRect& bounds):
|
||||
_baseWindow(baseWindow),
|
||||
_bounds(bounds),
|
||||
_error(false),
|
||||
_total(0),
|
||||
_progress(0),
|
||||
_progressX(0)
|
||||
{
|
||||
WINDOWINFO wi;
|
||||
wi.cbSize = sizeof(WINDOWINFO);
|
||||
baseWindow->GetWindowInfo(&wi);
|
||||
_bounds.OffsetRect(-wi.rcClient.left, -wi.rcClient.top);
|
||||
}
|
||||
|
||||
|
||||
// Get the current color
|
||||
inline COLORREF ProgressBar::getStatusColor()
|
||||
{
|
||||
return _error ? RGB(255, 0, 0) : RGB(0, 255, 0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // ProgressBar_INCLUDED
|
@ -0,0 +1,106 @@
|
||||
#ifndef SYNCHRONIZEDTESTRESULTDECORATOR_H
|
||||
#define SYNCHRONIZEDTESTRESULTDECORATOR_H
|
||||
|
||||
#include <afxmt.h>
|
||||
#include "TestResultDecorator.h"
|
||||
|
||||
class SynchronizedTestResult : public TestResultDecorator
|
||||
{
|
||||
public:
|
||||
SynchronizedTestResult (TestResult *result);
|
||||
~SynchronizedTestResult ();
|
||||
|
||||
|
||||
bool shouldStop ();
|
||||
void addError (Test *test, CppUnitException *e);
|
||||
void addFailure (Test *test, CppUnitException *e);
|
||||
void startTest (Test *test);
|
||||
void endTest (Test *test);
|
||||
int runTests ();
|
||||
int testErrors ();
|
||||
int testFailures ();
|
||||
bool wasSuccessful ();
|
||||
void stop ();
|
||||
|
||||
vector<TestFailure *>& errors ();
|
||||
vector<TestFailure *>& failures ();
|
||||
|
||||
private:
|
||||
CCriticalSection m_criticalSection;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Constructor
|
||||
inline SynchronizedTestResult::SynchronizedTestResult (TestResult *result)
|
||||
: TestResultDecorator (result) {}
|
||||
|
||||
// Destructor
|
||||
inline SynchronizedTestResult::~SynchronizedTestResult ()
|
||||
{}
|
||||
|
||||
// Returns whether the test should stop
|
||||
inline bool SynchronizedTestResult::shouldStop ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->shouldStop (); }
|
||||
|
||||
|
||||
// Adds an error to the list of errors. The passed in exception
|
||||
// caused the error
|
||||
inline void SynchronizedTestResult::addError (Test *test, CppUnitException *e)
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); m_result->addError (test, e); }
|
||||
|
||||
|
||||
// Adds a failure to the list of failures. The passed in exception
|
||||
// caused the failure.
|
||||
inline void SynchronizedTestResult::addFailure (Test *test, CppUnitException *e)
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); m_result->addFailure (test, e); }
|
||||
|
||||
|
||||
// Informs the result that a test will be started.
|
||||
inline void SynchronizedTestResult::startTest (Test *test)
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); m_result->startTest (test); }
|
||||
|
||||
|
||||
// Informs the result that a test was completed.
|
||||
inline void SynchronizedTestResult::endTest (Test *test)
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); m_result->endTest (test); }
|
||||
|
||||
|
||||
// Gets the number of run tests.
|
||||
inline int SynchronizedTestResult::runTests ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->runTests (); }
|
||||
|
||||
|
||||
// Gets the number of detected errors.
|
||||
inline int SynchronizedTestResult::testErrors ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->testErrors (); }
|
||||
|
||||
|
||||
// Gets the number of detected failures.
|
||||
inline int SynchronizedTestResult::testFailures ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->testFailures (); }
|
||||
|
||||
|
||||
// Returns whether the entire test was successful or not.
|
||||
inline bool SynchronizedTestResult::wasSuccessful ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->wasSuccessful (); }
|
||||
|
||||
|
||||
// Marks that the test run should stop.
|
||||
inline void SynchronizedTestResult::stop ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); m_result->stop (); }
|
||||
|
||||
|
||||
// Returns a vector of the errors.
|
||||
inline vector<TestFailure *>& SynchronizedTestResult::errors ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->errors (); }
|
||||
|
||||
|
||||
// Returns a vector of the failures.
|
||||
inline vector<TestFailure *>& SynchronizedTestResult::failures ()
|
||||
{ CSingleLock sync (&m_criticalSection, TRUE); return m_result->failures (); }
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
102
contrib/libpoco/CppUnit/WinTestRunner/src/TestResultDecorator.h
Normal file
102
contrib/libpoco/CppUnit/WinTestRunner/src/TestResultDecorator.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef CPP_UNIT_TESTRESULTDECORATOR_H
|
||||
#define CPP_UNIT_TESTRESULTDECORATOR_H
|
||||
|
||||
#include "TestResult.h"
|
||||
|
||||
class TestResultDecorator
|
||||
{
|
||||
public:
|
||||
TestResultDecorator (TestResult *result);
|
||||
virtual ~TestResultDecorator ();
|
||||
|
||||
|
||||
virtual bool shouldStop ();
|
||||
virtual void addError (Test *test, CppUnitException *e);
|
||||
virtual void addFailure (Test *test, CppUnitException *e);
|
||||
virtual void startTest (Test *test);
|
||||
virtual void endTest (Test *test);
|
||||
virtual int runTests ();
|
||||
virtual int testErrors ();
|
||||
virtual int testFailures ();
|
||||
virtual bool wasSuccessful ();
|
||||
virtual void stop ();
|
||||
|
||||
vector<TestFailure *>& errors ();
|
||||
vector<TestFailure *>& failures ();
|
||||
|
||||
protected:
|
||||
TestResult *m_result;
|
||||
};
|
||||
|
||||
|
||||
inline TestResultDecorator::TestResultDecorator (TestResult *result)
|
||||
: m_result (result) {}
|
||||
|
||||
inline TestResultDecorator::~TestResultDecorator ()
|
||||
{}
|
||||
|
||||
// Returns whether the test should stop
|
||||
inline bool TestResultDecorator::shouldStop ()
|
||||
{ return m_result->shouldStop (); }
|
||||
|
||||
|
||||
// Adds an error to the list of errors. The passed in exception
|
||||
// caused the error
|
||||
inline void TestResultDecorator::addError (Test *test, CppUnitException *e)
|
||||
{ m_result->addError (test, e); }
|
||||
|
||||
|
||||
// Adds a failure to the list of failures. The passed in exception
|
||||
// caused the failure.
|
||||
inline void TestResultDecorator::addFailure (Test *test, CppUnitException *e)
|
||||
{ m_result->addFailure (test, e); }
|
||||
|
||||
|
||||
// Informs the result that a test will be started.
|
||||
inline void TestResultDecorator::startTest (Test *test)
|
||||
{ m_result->startTest (test); }
|
||||
|
||||
|
||||
// Informs the result that a test was completed.
|
||||
inline void TestResultDecorator::endTest (Test *test)
|
||||
{ m_result->endTest (test); }
|
||||
|
||||
|
||||
// Gets the number of run tests.
|
||||
inline int TestResultDecorator::runTests ()
|
||||
{ return m_result->runTests (); }
|
||||
|
||||
|
||||
// Gets the number of detected errors.
|
||||
inline int TestResultDecorator::testErrors ()
|
||||
{ return m_result->testErrors (); }
|
||||
|
||||
|
||||
// Gets the number of detected failures.
|
||||
inline int TestResultDecorator::testFailures ()
|
||||
{ return m_result->testFailures (); }
|
||||
|
||||
|
||||
// Returns whether the entire test was successful or not.
|
||||
inline bool TestResultDecorator::wasSuccessful ()
|
||||
{ return m_result->wasSuccessful (); }
|
||||
|
||||
|
||||
// Marks that the test run should stop.
|
||||
inline void TestResultDecorator::stop ()
|
||||
{ m_result->stop (); }
|
||||
|
||||
|
||||
// Returns a vector of the errors.
|
||||
inline vector<TestFailure *>& TestResultDecorator::errors ()
|
||||
{ return m_result->errors (); }
|
||||
|
||||
|
||||
// Returns a vector of the failures.
|
||||
inline vector<TestFailure *>& TestResultDecorator::failures ()
|
||||
{ return m_result->failures (); }
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
439
contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp
Normal file
439
contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp
Normal file
@ -0,0 +1,439 @@
|
||||
//
|
||||
// TestRunnerDlg.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/TestRunnerDlg.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include <afxwin.h>
|
||||
#include <afxext.h>
|
||||
#include <afxcmn.h>
|
||||
#include <mmsystem.h>
|
||||
#include "TestRunnerDlg.h"
|
||||
#include "ActiveTest.h"
|
||||
#include "GUITestResult.h"
|
||||
#include "ProgressBar.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "TestRunnerDlg.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
TestRunnerDlg::TestRunnerDlg(CWnd* pParent): CDialog(TestRunnerDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(TestRunnerDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
|
||||
_testsProgress = 0;
|
||||
_selectedTest = 0;
|
||||
_currentTest = 0;
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(TestRunnerDlg)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(TestRunnerDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(TestRunnerDlg)
|
||||
ON_BN_CLICKED(ID_RUN, OnRun)
|
||||
ON_BN_CLICKED(ID_STOP, OnStop)
|
||||
ON_CBN_SELCHANGE(IDC_COMBO_TEST, OnSelchangeComboTest)
|
||||
ON_BN_CLICKED(IDC_CHK_AUTORUN, OnBnClickedAutorun)
|
||||
ON_WM_PAINT()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
BOOL TestRunnerDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
CListCtrl *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST);
|
||||
CComboBox *comboBox = (CComboBox *)GetDlgItem (IDC_COMBO_TEST);
|
||||
|
||||
ASSERT (listCtrl);
|
||||
ASSERT (comboBox);
|
||||
|
||||
CString title;
|
||||
GetWindowText(title);
|
||||
#if defined(_DEBUG)
|
||||
title.Append(" [debug]");
|
||||
#else
|
||||
title.Append(" [release]");
|
||||
#endif
|
||||
SetWindowText(title);
|
||||
|
||||
listCtrl->InsertColumn (0,"Type", LVCFMT_LEFT, 16 + listCtrl->GetStringWidth ("Type"), 1);
|
||||
listCtrl->InsertColumn (1,"Name", LVCFMT_LEFT, 16 * listCtrl->GetStringWidth ("X"), 2);
|
||||
listCtrl->InsertColumn (2,"Failed Condition", LVCFMT_LEFT, 24 * listCtrl->GetStringWidth ("M"), 3);
|
||||
listCtrl->InsertColumn (3,"Line", LVCFMT_LEFT, 16 + listCtrl->GetStringWidth ("0000"), 4);
|
||||
listCtrl->InsertColumn (4,"File Name", LVCFMT_LEFT, 36 * listCtrl->GetStringWidth ("M"), 5);
|
||||
|
||||
int numberOfCases = 0;
|
||||
|
||||
CWinApp* pApp = AfxGetApp();
|
||||
CString lastTestCS = pApp->GetProfileString("Tests", "lastTest");
|
||||
std::string lastTest((LPCSTR) lastTestCS);
|
||||
int sel = -1;
|
||||
for (std::vector<TestInfo>::iterator it = _tests.begin (); it != _tests.end (); ++it)
|
||||
{
|
||||
std::string cbName(it->level*4, ' ');
|
||||
cbName.append(it->pTest->toString());
|
||||
comboBox->AddString (cbName.c_str ());
|
||||
if (sel < 0)
|
||||
{
|
||||
if (lastTest.empty() || lastTest == it->pTest->toString())
|
||||
{
|
||||
_selectedTest = it->pTest;
|
||||
sel = numberOfCases;
|
||||
}
|
||||
}
|
||||
numberOfCases++;
|
||||
}
|
||||
|
||||
if (numberOfCases > 0)
|
||||
{
|
||||
if (sel < 0)
|
||||
{
|
||||
_selectedTest = _tests[0].pTest;
|
||||
sel = 0;
|
||||
}
|
||||
comboBox->SetCurSel (sel);
|
||||
}
|
||||
else
|
||||
{
|
||||
beRunDisabled ();
|
||||
}
|
||||
CWnd *pProgress = GetDlgItem(IDC_PROGRESS);
|
||||
CRect rect;
|
||||
pProgress->GetWindowRect(&rect);
|
||||
_testsProgress = new ProgressBar (this, rect);
|
||||
|
||||
CButton* autoRunBtn = (CButton*) GetDlgItem(IDC_CHK_AUTORUN);
|
||||
autoRunBtn->SetCheck(pApp->GetProfileInt("Tests", "autoRun", BST_UNCHECKED));
|
||||
|
||||
reset ();
|
||||
|
||||
if (autoRunBtn->GetCheck() == BST_CHECKED)
|
||||
{
|
||||
OnRun();
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
TestRunnerDlg::~TestRunnerDlg ()
|
||||
{
|
||||
freeState ();
|
||||
delete _testsProgress;
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::OnRun()
|
||||
{
|
||||
if (_selectedTest == 0)
|
||||
return;
|
||||
|
||||
freeState ();
|
||||
reset ();
|
||||
|
||||
beRunning ();
|
||||
|
||||
int numberOfTests = _selectedTest->countTestCases ();
|
||||
|
||||
_testsProgress->start (numberOfTests);
|
||||
|
||||
_result = new GUITestResult ((TestRunnerDlg *)this);
|
||||
_activeTest = new ActiveTest (_selectedTest);
|
||||
|
||||
_testStartTime = timeGetTime ();
|
||||
|
||||
_activeTest->run (_result);
|
||||
|
||||
_testEndTime = timeGetTime ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::addListEntry(const std::string& type, TestResult *result, Test *test, CppUnitException *e)
|
||||
{
|
||||
char stage [80];
|
||||
LV_ITEM lvi;
|
||||
CListCtrl *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST);
|
||||
int currentEntry = result->testErrors () + result->testFailures () -1;
|
||||
|
||||
sprintf (stage, "%s", type.c_str ());
|
||||
|
||||
lvi.mask = LVIF_TEXT;
|
||||
lvi.iItem = currentEntry;
|
||||
lvi.iSubItem = 0;
|
||||
lvi.pszText = stage;
|
||||
lvi.iImage = 0;
|
||||
lvi.stateMask = 0;
|
||||
lvi.state = 0;
|
||||
|
||||
listCtrl->InsertItem (&lvi);
|
||||
|
||||
// Set class string
|
||||
listCtrl->SetItemText (currentEntry, 1, test->toString ().c_str ());
|
||||
|
||||
// Set the asserted text
|
||||
listCtrl->SetItemText(currentEntry, 2, e->what ());
|
||||
|
||||
// Set the line number
|
||||
if (e->lineNumber () == CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
sprintf (stage, "<unknown>");
|
||||
else
|
||||
sprintf (stage, "%ld", e->lineNumber ());
|
||||
|
||||
listCtrl->SetItemText(currentEntry, 3, stage);
|
||||
|
||||
// Set the file name
|
||||
listCtrl->SetItemText(currentEntry, 4, e->fileName ().c_str ());
|
||||
|
||||
listCtrl->RedrawItems (currentEntry, currentEntry);
|
||||
listCtrl->UpdateWindow ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::addError (TestResult *result, Test *test, CppUnitException *e)
|
||||
{
|
||||
addListEntry ("Error", result, test, e);
|
||||
_errors++;
|
||||
|
||||
_currentTest = 0;
|
||||
updateCountsDisplay ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::addFailure (TestResult *result, Test *test, CppUnitException *e)
|
||||
{
|
||||
addListEntry ("Failure", result, test, e);
|
||||
_failures++;
|
||||
|
||||
_currentTest = 0;
|
||||
updateCountsDisplay ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::startTest(Test* test)
|
||||
{
|
||||
_currentTest = test;
|
||||
updateCountsDisplay();
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::endTest (TestResult *result, Test *test)
|
||||
{
|
||||
if (_selectedTest == 0)
|
||||
return;
|
||||
_currentTest = 0;
|
||||
|
||||
_testsRun++;
|
||||
updateCountsDisplay ();
|
||||
_testsProgress->step (_failures == 0 && _errors == 0);
|
||||
|
||||
_testEndTime = timeGetTime ();
|
||||
|
||||
updateCountsDisplay ();
|
||||
|
||||
if (_testsRun >= _selectedTest->countTestCases ())
|
||||
beIdle ();
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::beRunning ()
|
||||
{
|
||||
CButton *runButton = (CButton *)GetDlgItem (ID_RUN);
|
||||
CButton *closeButton = (CButton *)GetDlgItem (IDOK);
|
||||
|
||||
runButton->EnableWindow (FALSE);
|
||||
closeButton->EnableWindow (FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::beIdle ()
|
||||
{
|
||||
CButton *runButton = (CButton *)GetDlgItem (ID_RUN);
|
||||
CButton *closeButton = (CButton *)GetDlgItem (IDOK);
|
||||
|
||||
runButton->EnableWindow (TRUE);
|
||||
closeButton->EnableWindow (TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::beRunDisabled ()
|
||||
{
|
||||
CButton *runButton = (CButton *)GetDlgItem (ID_RUN);
|
||||
CButton *closeButton = (CButton *)GetDlgItem (IDOK);
|
||||
CButton *stopButton = (CButton *)GetDlgItem (ID_STOP);
|
||||
|
||||
runButton->EnableWindow (FALSE);
|
||||
stopButton->EnableWindow (FALSE);
|
||||
closeButton->EnableWindow (TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::freeState ()
|
||||
{
|
||||
delete _activeTest;
|
||||
delete _result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::reset ()
|
||||
{
|
||||
_testsRun = 0;
|
||||
_errors = 0;
|
||||
_failures = 0;
|
||||
_testEndTime = _testStartTime;
|
||||
|
||||
updateCountsDisplay ();
|
||||
|
||||
_activeTest = 0;
|
||||
_result = 0;
|
||||
|
||||
CListCtrl *listCtrl = (CListCtrl *)GetDlgItem (IDC_LIST);
|
||||
|
||||
listCtrl->DeleteAllItems ();
|
||||
_testsProgress->reset ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::updateCountsDisplay ()
|
||||
{
|
||||
CStatic *statTestsRun = (CStatic *)GetDlgItem (IDC_STATIC_RUNS);
|
||||
CStatic *statErrors = (CStatic *)GetDlgItem (IDC_STATIC_ERRORS);
|
||||
CStatic *statFailures = (CStatic *)GetDlgItem (IDC_STATIC_FAILURES);
|
||||
CEdit *editTime = (CEdit *)GetDlgItem (IDC_EDIT_TIME);
|
||||
|
||||
CString argumentString;
|
||||
|
||||
argumentString.Format ("%d", _testsRun);
|
||||
statTestsRun ->SetWindowText (argumentString);
|
||||
|
||||
argumentString.Format ("%d", _errors);
|
||||
statErrors ->SetWindowText (argumentString);
|
||||
|
||||
argumentString.Format ("%d", _failures);
|
||||
statFailures ->SetWindowText (argumentString);
|
||||
|
||||
if (_currentTest)
|
||||
argumentString.Format ("Execution Time: %3.3lf seconds, Current Test: %s", (_testEndTime - _testStartTime) / 1000.0, _currentTest->toString().c_str());
|
||||
else
|
||||
argumentString.Format ("Execution Time: %3.3lf seconds", (_testEndTime - _testStartTime) / 1000.0);
|
||||
|
||||
editTime ->SetWindowText (argumentString);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::OnStop()
|
||||
{
|
||||
if (_result)
|
||||
_result->stop ();
|
||||
|
||||
beIdle ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::OnOK()
|
||||
{
|
||||
if (_result)
|
||||
_result->stop ();
|
||||
|
||||
CDialog::OnOK ();
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::OnSelchangeComboTest()
|
||||
{
|
||||
CComboBox *testsSelection = (CComboBox *)GetDlgItem (IDC_COMBO_TEST);
|
||||
|
||||
int currentSelection = testsSelection->GetCurSel ();
|
||||
|
||||
if (currentSelection >= 0 && currentSelection < _tests.size ())
|
||||
{
|
||||
_selectedTest = (_tests.begin () + currentSelection)->pTest;
|
||||
beIdle ();
|
||||
CWinApp* pApp = AfxGetApp();
|
||||
pApp->WriteProfileString("Tests", "lastTest", _selectedTest->toString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedTest = 0;
|
||||
beRunDisabled ();
|
||||
|
||||
}
|
||||
|
||||
freeState ();
|
||||
reset ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::OnBnClickedAutorun()
|
||||
{
|
||||
CButton *autoRunBtn = (CButton *)GetDlgItem (IDC_CHK_AUTORUN);
|
||||
CWinApp* pApp = AfxGetApp();
|
||||
pApp->WriteProfileInt("Tests", "autoRun", autoRunBtn->GetCheck());
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc (this);
|
||||
|
||||
_testsProgress->paint (dc);
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::setTests(const std::vector<Test*>& tests)
|
||||
{
|
||||
_tests.clear();
|
||||
for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it)
|
||||
{
|
||||
addTest(*it, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TestRunnerDlg::addTest(Test* pTest, int level)
|
||||
{
|
||||
TestInfo ti;
|
||||
ti.pTest = pTest;
|
||||
ti.level = level;
|
||||
_tests.push_back(ti);
|
||||
TestSuite* pSuite = dynamic_cast<TestSuite*>(pTest);
|
||||
if (pSuite)
|
||||
{
|
||||
const std::vector<Test*>& tests = pSuite->tests();
|
||||
for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it)
|
||||
{
|
||||
addTest(*it, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
94
contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.h
Normal file
94
contrib/libpoco/CppUnit/WinTestRunner/src/TestRunnerDlg.h
Normal file
@ -0,0 +1,94 @@
|
||||
//
|
||||
// TestRunnerDlg.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/TestRunnerDlg.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef TestRunnerDlg_INCLUDED
|
||||
#define TestRunnerDlg_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
#include "ActiveTest.h"
|
||||
#include <vector>
|
||||
#include "../res/Resource.h"
|
||||
#include <afxwin.h>
|
||||
#include "afxwin.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class ProgressBar;
|
||||
|
||||
|
||||
class TestRunnerDlg: public CDialog
|
||||
{
|
||||
public:
|
||||
TestRunnerDlg(CWnd* pParent = NULL);
|
||||
~TestRunnerDlg();
|
||||
|
||||
void setTests(const std::vector<Test*>& tests);
|
||||
|
||||
void addError(TestResult* result, Test* test, CppUnitException* e);
|
||||
void addFailure(TestResult* result, Test* test, CppUnitException* e);
|
||||
void startTest(Test* test);
|
||||
void endTest(TestResult* result, Test* test);
|
||||
|
||||
//{{AFX_DATA(TestRunnerDlg)
|
||||
enum { IDD = IDD_DIALOG_TESTRUNNER };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
//{{AFX_VIRTUAL(TestRunnerDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
protected:
|
||||
//{{AFX_MSG(TestRunnerDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnRun();
|
||||
afx_msg void OnStop();
|
||||
virtual void OnOK();
|
||||
afx_msg void OnSelchangeComboTest();
|
||||
afx_msg void OnBnClickedAutorun();
|
||||
afx_msg void OnPaint();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
void addListEntry(const std::string& type, TestResult* result, Test* test, CppUnitException* e);
|
||||
void beIdle();
|
||||
void beRunning();
|
||||
void beRunDisabled();
|
||||
void reset();
|
||||
void freeState();
|
||||
void updateCountsDisplay();
|
||||
void addTest(Test* pTest, int level);
|
||||
|
||||
struct TestInfo
|
||||
{
|
||||
Test* pTest;
|
||||
int level;
|
||||
};
|
||||
std::vector<TestInfo> _tests;
|
||||
ProgressBar* _testsProgress;
|
||||
Test* _selectedTest;
|
||||
ActiveTest* _activeTest;
|
||||
TestResult* _result;
|
||||
int _testsRun;
|
||||
int _errors;
|
||||
int _failures;
|
||||
DWORD _testStartTime;
|
||||
DWORD _testEndTime;
|
||||
Test* _currentTest;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // TestRunnerDlg_INCLUDED
|
||||
|
108
contrib/libpoco/CppUnit/WinTestRunner/src/WinTestRunner.cpp
Normal file
108
contrib/libpoco/CppUnit/WinTestRunner/src/WinTestRunner.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
//
|
||||
// WinTestRunner.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/WinTestRunner/src/WinTestRunner.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "WinTestRunner/WinTestRunner.h"
|
||||
#include "TestRunnerDlg.h"
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
WinTestRunner::WinTestRunner()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
WinTestRunner::~WinTestRunner()
|
||||
{
|
||||
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
|
||||
void WinTestRunner::run()
|
||||
{
|
||||
// Note: The following code is some evil hack to
|
||||
// add batch capability to the MFC based WinTestRunner.
|
||||
|
||||
std::string cmdLine(AfxGetApp()->m_lpCmdLine);
|
||||
if (cmdLine.size() >= 2 && cmdLine[0] == '/' && (cmdLine[1] == 'b' || cmdLine[1] == 'B'))
|
||||
{
|
||||
TestRunner runner;
|
||||
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
|
||||
runner.addTest((*it)->toString(), *it);
|
||||
_tests.clear();
|
||||
std::vector<std::string> args;
|
||||
args.push_back("WinTestRunner");
|
||||
args.push_back("-all");
|
||||
bool success = runner.run(args);
|
||||
ExitProcess(success ? 0 : 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We're running in interactive mode.
|
||||
TestRunnerDlg dlg;
|
||||
dlg.setTests(_tests);
|
||||
dlg.DoModal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WinTestRunner::addTest(Test* pTest)
|
||||
{
|
||||
_tests.push_back(pTest);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(WinTestRunnerApp, CWinApp)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
BOOL WinTestRunnerApp::InitInstance()
|
||||
{
|
||||
std::string cmdLine(AfxGetApp()->m_lpCmdLine);
|
||||
if (cmdLine.size() >= 2 && cmdLine[0] == '/' && (cmdLine[1] == 'b' || cmdLine[1] == 'B'))
|
||||
{
|
||||
// We're running in batch mode.
|
||||
std::string outPath;
|
||||
if (cmdLine.size() > 4 && cmdLine[2] == ':')
|
||||
{
|
||||
outPath = cmdLine.substr(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
char buffer[1024];
|
||||
GetModuleFileName(NULL, buffer, sizeof(buffer));
|
||||
outPath = buffer;
|
||||
outPath += ".out";
|
||||
}
|
||||
freopen(outPath.c_str(), "w", stdout);
|
||||
freopen(outPath.c_str(), "w", stderr);
|
||||
TestMain();
|
||||
}
|
||||
else
|
||||
{
|
||||
AllocConsole();
|
||||
SetConsoleTitle("CppUnit WinTestRunner Console");
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
freopen("CONOUT$", "w", stderr);
|
||||
freopen("CONIN$", "r", stdin);
|
||||
TestMain();
|
||||
FreeConsole();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void WinTestRunnerApp::TestMain()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
75
contrib/libpoco/CppUnit/doc/README.html
Normal file
75
contrib/libpoco/CppUnit/doc/README.html
Normal file
@ -0,0 +1,75 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<META NAME="Generator" CONTENT="Microsoft Word 97">
|
||||
<TITLE>CppUnit 1.5</TITLE>
|
||||
<META NAME="Template" CONTENT="C:\Program Files\MSOffice\Office\html.dot">
|
||||
</HEAD>
|
||||
<BODY LINK="#0000ff" VLINK="#800080">
|
||||
|
||||
<P><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"></P>
|
||||
<H1>CppUnit 1.5</H1>
|
||||
<P>Last Revision: 12/15/99 - Michael Feathers (mfeathers@acm.org) - written in standard C++, tested under Microsoft Visual C++ 6.0</P>
|
||||
<P><HR></P>
|
||||
<H3>Background</H3>
|
||||
<P>CppUnit is a simple unit test framework for C++. It is a port from JUnit, a testing framework for Java, developed by Kent Beck and Erich Gamma. </P>
|
||||
<H3>Contents</H3>
|
||||
<PRE>README.html this file
|
||||
|
||||
test the source code
|
||||
framework the testing framework
|
||||
		extensions	some framework extension classes
|
||||
textui a command line interface to run tests
|
||||
ms code for a Microsoft specific TestRunner
|
||||
samples some example test cases and extensions to the framework
|
||||
multicaster a sample illustrating a publish/subscribe
|
||||
				multicaster under test
|
||||
doc documentation</PRE>
|
||||
<H3>Installation</H3>
|
||||
<P>To use the test framework, create a makefile or load all files in test\framework into your IDE. In this incarnation of CppUnit, all includes assume the current directory first. A makefile or project can be used to resolve the dependencies. </P>
|
||||
<P>The directory test\textui contains a simple command line example that uses the framework.</P>
|
||||
<H3>Documentation</H3>
|
||||
<P>CppUnit comes with the following documentation: </P>
|
||||
|
||||
<UL>
|
||||
<LI>a cookbook: doc\cookbook.htm </LI>
|
||||
<LI>this file </LI></UL>
|
||||
|
||||
<H3>Samples</H3>
|
||||
<P>You can find several sample test cases in the samples directory: </P>
|
||||
|
||||
<UL>
|
||||
<LI>ExampleTestCase - some simple tests </LI>
|
||||
<LI>Multicaster - test cases for a sample publish/subscribe multicaster class </LI></UL>
|
||||
|
||||
<P>Also, the wiki page <a HREF="http://c2.com/cgi/wiki?ClassHierarchyTestingInCppUnit">http://c2.com/cgi/wiki?ClassHierarchyTestingInCppUnit</a> shows how to automatically apply tests of classes to the classes' subclasses.</P>
|
||||
|
||||
<H3>Extensions</H3>
|
||||
<P>You can find several classes that illustrate framework extensions in the extensions directory: </P>
|
||||
|
||||
<UL>
|
||||
<LI>TestDecorator - A Decorator for Test. You can use it as the base class for decorators that extend test cases. </LI>
|
||||
<LI>TestSetup - A Decorator that can be used to set up and tear down additional fixture state. Subclass TestSetup and insert it into your tests when you want to set up additional state once before the test is run. </LI>
|
||||
<LI>Orthodox - a template class which can be used to verify operations on an arbitrary class.</LI></UL>
|
||||
|
||||
|
||||
<H3>Notes</H3>
|
||||
<P>Porting this framework has been fun. I've tried to maintain the spirit and utility of JUnit in a C++ environment. Naturally, the move from Java to standard C++ forces out several nice JUnit features:</P>
|
||||
<OL>
|
||||
|
||||
<LI>Platform independent GUI.</LI>
|
||||
<LI>Stack traces of test failures</LI>
|
||||
<LI>Active (threaded) tests</LI>
|
||||
<LI>Direct invocation of test cases via reflection</LI>
|
||||
<LI>Run-time loading of new tests</LI></OL>
|
||||
|
||||
<P>In addition, the lack of garbage collection in C++ requires some careful use of the framework classes. In particular, TestSuites are composites that manage the lifetime of any tests added to them. Holding onto a TestResult past the lifetime of the tests which filled it is a bad idea. This is because TestResults hold TestFailures and TestFailures hold pointers to the Tests that generated them.</P>
|
||||
<P>On the plus side, we can use the C++ macro preprocessor to get the exact line at which a failure occurs, along with the actual text inside the assert () call that detected the failure. The features of C++ that enable this are the __LINE__ and __FILE__ preprocessor definitions, along with the <I>stringizing</I> operator. If you find that generating this much literal text bulks up your test executables, you can use the CPP_UNIT_SOURCEANNOT define to disable that portion of the reporting.</P>
|
||||
<P>Note: If you use the C++ macro "assert ()" in your code, or include assert.h, you may have a name clash with CppUnit's assert macro. This can be remedied by changing the name of the macro to "cu_assert ()" in TestCase.h.</P>
|
||||
<P>I'd like to thank Kent Beck and Erich Gamma for the inspiration, design, and a wonderful cookbook that was easily/shamelessly mutated to describe CppUnit. Double thanks to Erich for thinking up a way to implement TestCaller. Additional thanks to Kent, Ward Cunningham, Ron Jeffries, Martin Fowler, and several other netizens of the WikiWikiWeb. I don't think any other bunch of people could have convinced me that rapid development with unit tests can be both effective and easy.</P>
|
||||
<P>Thanks also to Fred Huls for mentioning the idea of template-based testing. The <EM>orthodox</EM> template class demonstrates only a small part of what can be done with templated test cases.</P>
|
||||
<H3>History Of Changes</H3>
|
||||
<P>1.2 -- Added the TestCaller template class. There is now no need to use the CPP_UNIT_TESTCASEDISPATCH macro unless you are using a C++ compiler which does not support templates well. CPP_UNIT_TESTCASEDISPATCH remains in TestCase.h for backward compatibility. I've also kept the use of the macro in the Multicaster sample to leave in an example.</P>
|
||||
<P>1.3 -- Retired the CPP_UNIT_TESTCASEDISPATCH macro and cleaned up the include structure. Fixed bug in the textui version.</P>
|
||||
<P>1.4 -- Removed using directives for std in CppUnit headers. Merged the old AssertionFailedError into CppUnitException. Fixed a memory leak in the TestRunner class of the MS GUI TestRunner. Removed CppUnit.h file. Now headers for each class must be included directly.</P></BODY></HTML>
|
||||
<P>1.5 -- Upgraded projects from VC++ 5.0 to 6.0.</P></BODY></HTML>
|
164
contrib/libpoco/CppUnit/doc/cookbook.htm
Normal file
164
contrib/libpoco/CppUnit/doc/cookbook.htm
Normal file
@ -0,0 +1,164 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<META NAME="Generator" CONTENT="Microsoft Word 97">
|
||||
<TITLE>CppUnit Cookbook</TITLE>
|
||||
<META NAME="Template" CONTENT="C:\Program Files\MSOffice\Office\html.dot">
|
||||
</HEAD>
|
||||
<BODY LINK="#0000ff" VLINK="#800080">
|
||||
|
||||
<P><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"></P>
|
||||
<H1>CppUnit Cookbook</H1>
|
||||
<P>Here is a short cookbook to help you get started. </P>
|
||||
<H2>Simple Test Case</H2>
|
||||
<P>You want to know whether your code is working. How do you do it? There are many ways. Stepping through a debugger or littering your code with stream output calls are two of the simpler ways, but they both have drawbacks. Stepping through your code is a good idea, but it is not automatic. You have to do it every time you make changes. Streaming out text is also fine, but it makes code ugly and it generates far more information than you need most of the time.</P>
|
||||
<P>Tests in CppUnit can be run automatically. They are easy to set up and once you have written them, they are always there to help you keep confidence in the quality of your code.</P>
|
||||
<P>To make a simple test, here is what you do:</P>
|
||||
<P>Subclass the TestCase class. Override the method "runTest ()". When you want to check a value, call "assert (bool)" and pass in an expression that is true if the test succeeds. </P>
|
||||
<P>For example, to test the equality comparison for a Complex number class, write:</P>
|
||||
<TT><PRE>	class ComplexNumberTest : public TestCase {
|
||||
	public:
|
||||
ComplexNumberTest (string name) : TestCase (name) {}
|
||||
void runTest () {
|
||||
assert (Complex (10, 1) == Complex (10, 1));
|
||||
assert (!(Complex (1, 1) == Complex (2, 2)));
|
||||
}
|
||||
};</PRE>
|
||||
</TT><P>That was a very simple test. Ordinarily, you'll have many little test cases that you'll want to run on the same set of objects. To do this, use a fixture.</P>
|
||||
<P> </P>
|
||||
<H2>Fixture</H2>
|
||||
<P>A fixture is a known set of objects that serves as a base for a set of test cases. Fixtures come in very handy when you are testing as you develop. Let's try out this style of development and learn about fixtures along the away. Suppose that we are really developing a complex number class. Let's start by defining a empty class named Complex.</P>
|
||||
<TT><PRE>	class Complex {}; </PRE>
|
||||
</TT><P>Now create an instance of ComplexNumberTest above, compile the code and see what happens. The first thing we notice is a few compiler errors. The test uses operator==, but it is not defined. Let's fix that.</P>
|
||||
<TT><PRE>	bool operator== (const Complex& a, const Complex& b) { return true; }</PRE>
|
||||
</TT><P>Now compile the test, and run it. This time it compiles but the test fails. We need a bit more to get an operator== working correctly, so we revisit the code.</P>
|
||||
<TT><PRE>	class Complex {
|
||||
friend bool operator== (const Complex& a, const Complex& b);
|
||||
double real, imaginary;
|
||||
public:
|
||||
Complex () {
|
||||
real = imaginary = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
bool operator== (const Complex& a, const Complex& b)
|
||||
{ return eq(a.real,b.real) && eq(a.imaginary,b.imaginary); }</PRE>
|
||||
</TT><P>If we compile now and run our test it will pass. </P>
|
||||
<P>Now we are ready to add new operations and new tests. At this point a fixture would be handy. We would probably be better off when doing our tests if we decided to instantiate three or four complex numbers and reuse them across our tests. </P>
|
||||
<P>Here is how we do it:</P>
|
||||
<OL>
|
||||
|
||||
<LI>Add member variables for each part of the fixture </LI>
|
||||
<LI>Override "setUp ()" to initialize the variables </LI>
|
||||
<LI>Override "tearDown ()" to release any permanent resources you allocated in "setUp ()"</LI></OL>
|
||||
|
||||
<TT><PRE>	class ComplexNumberTest : public TestCase {
|
||||
	private:
|
||||
Complex 	*m_10_1, *m_1_1; *m_11_2;
|
||||
	protected:
|
||||
	void		setUp () {
|
||||
			 m_10_1 = new Complex (10, 1);
|
||||
			 m_1_1 = new Complex (1, 1);
|
||||
			 m_11_2 = new Complex (11, 2);
|
||||
}
|
||||
	void		tearDown () {
|
||||
			 delete m_10_1, delete m_1_1, delete m_11_2;
|
||||
			}
|
||||
	};</PRE>
|
||||
</TT><P>Once we have this fixture, we can add the complex addition test case any any others that we need over the course of our development.</P>
|
||||
<P> </P>
|
||||
<H2>Test Case</H2>
|
||||
<P>How do you write and invoke individual tests using a fixture? </P>
|
||||
<P>There are two steps to this process:</P>
|
||||
<OL>
|
||||
|
||||
<LI>Write the test case as a method in the fixture class</LI>
|
||||
<LI>Create a TestCaller which runs that particular method</LI></OL>
|
||||
|
||||
<P>Here is our test case class with a few extra case methods:</P>
|
||||
<TT><PRE>	class ComplexNumberTest : public TestCase {
|
||||
	private:
|
||||
Complex 	*m_10_1, *m_1_1; *m_11_2;
|
||||
	protected:
|
||||
	void		setUp () {
|
||||
			 m_10_1 = new Complex (10, 1);
|
||||
			 m_1_1 = new Complex (1, 1);
|
||||
			 m_11_2 = new Complex (11, 2);
|
||||
}
|
||||
	void		tearDown () {
|
||||
			 delete m_10_1, delete m_1_1, delete m_11_2;
|
||||
			}
|
||||
	void		testEquality () {
|
||||
			 assert (*m_10_1 == *m_10_1);
|
||||
			 assert (!(*m_10_1 == *m_11_2));
|
||||
			}
|
||||
	void		testAddition () {
|
||||
			 assert (*m_10_1 + *m_1_1 == *m_11_2);
|
||||
	}
|
||||
	};</PRE>
|
||||
</TT><P>Create and run instances for each test case like this:</P>
|
||||
<TT><PRE>	test = new TestCaller<ComplexNumberTest>("testEquality", ComplexNumberTest::testEquality);
|
||||
test->run (); </PRE>
|
||||
</TT><P>The second argument to the test caller constructor is the address of a method on ComplexNumberTest. When the test caller is run, that specific method will be run.</P>
|
||||
<P>Once you have several tests, organize them into a suite.</P>
|
||||
<P> </P>
|
||||
<H2>Suite</H2>
|
||||
<P>How do you set up your tests so that you can run them all at once?<BR>
|
||||
<BR>
|
||||
CppUnit provides a TestSuite class that runs any number of TestCases together. For example, to run a single test case, you execute:</P>
|
||||
<TT><PRE>	TestResult result;
|
||||
	TestCaller<ComplexNumberTest> test ("testAddition", ComplexNumberTest::testAddition);
|
||||
	Test.run (&result);</PRE>
|
||||
</TT><P> </P>
|
||||
<P>To create a suite of two or more tests, you do the following:</P>
|
||||
<TT><PRE>	TestSuite suite;
|
||||
	TestResult result;
|
||||
	suite.addTest (new TestCaller<ComplexNumberTest>("testEquality", ComplexNumberTest::testEquality));
|
||||
	suite.addTest (new TestCaller<ComplexNumberTest>("testAddition", ComplexNumberTest::testAddition));
|
||||
	suite.run (&result);
|
||||
</PRE>
|
||||
</TT><P>TestSuites don't only have to contain callers for TestCases. They can contain any object that implements the Test interface. For example, you can create a TestSuite in your code and I can create one in mine, and we can run them together by creating a TestSuite that contains both: </P>
|
||||
<TT><PRE>	TestSuite suite;
|
||||
	suite.addTest (ComplexNumberTest.suite ());
|
||||
	suite.addTest (SurrealNumberTest.suite ());
|
||||
	suite.run (&result);</PRE>
|
||||
</TT><P> </P>
|
||||
<H2>TestRunner</H2>
|
||||
<P>How do you run your tests and collect their results? </P>
|
||||
<P>Once you have a test suite, you'll want to run it. CppUnit provides tools to define the suite to be run and to display its results. You make your suite accessible to a TestRunner program with a static method <I>suite</I> that returns a test suite. <BR>
|
||||
For example, to make a ComplexNumberTest suite available to a TestRunner, add the following code to ComplexNumberTest: </P>
|
||||
<TT><PRE>	public: static Test *suite () {
|
||||
	 TestSuite *suiteOfTests = new TestSuite;
|
||||
	 suiteOfTests->addTest (new TestCaller<ComplexNumberTest>("testEquality", testEquality));
|
||||
	 suiteOfTests->addTest (new TestCaller<ComplexNumberTest>("testAddition", testAddition));
|
||||
return suiteOfTests;
|
||||
	}</PRE>
|
||||
</TT><P>CppUnit provides both a textual version of a TestRunner tool, and a Micosoft Visual C++ 5.0 graphical version. If you are running on another platform, take a look at the graphical version. It is easy to port.</P>
|
||||
<P>To use the text version, include the header file for the test in TestRunner.cpp:</P>
|
||||
<TT><PRE>	#include "ExampleTestCase.h"
|
||||
	#include "ComplexNumberTest.h"</PRE>
|
||||
</TT><P>And add a call to "addTest (string, Test *) in the "main ()" function:</P>
|
||||
<TT><PRE>	int main (int ac, char **av) {
|
||||
	 TestRunner runner;
|
||||
	 runner.addTest (ExampleTestCase::suite ());
|
||||
	 runner.addTest (ComplexNumberTest::suite ());
|
||||
	 runner.run ();
|
||||
	 return 0;
|
||||
	}</PRE>
|
||||
</TT><P>The TestRunner will run the tests. If all the tests pass, you'll get an informative message. If any fail, you'll get the following information:</P>
|
||||
<OL>
|
||||
|
||||
<LI>The name of the test case that failed</LI>
|
||||
<LI>The name of the source file that contains the test</LI>
|
||||
<LI>The line number where the failure occurred</LI>
|
||||
<LI>All of the text inside the call to assert which detected the failure</LI></OL>
|
||||
|
||||
<P>CppUnit distinguishes between <I>failures</I> and <I>errors</I>. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like division by zero and other exceptions thrown by the C++ runtime or your code.</P>
|
||||
<P>If you are running MS Developer's Studio, you can build the GUI version rather easily. There are three projects: culib, TestRunner, and HostApp. They make a static library for the framework, a dialog based TestRunner in a DLL and an example Hosting application, respectively. To incorporate a TestRunner in an application you are developing, link with the static library and the TestRunner DLL. Note that the TestRunner DLL must be in the home directory of your application, the system directory or the path. In your application, create an instance of TestRunnerDlg whenever you want to run tests. Pass tests you want to run to the dialog object and then execute.</P>
|
||||
<P>Here is a screen shot of the TestRunner in use:</P>
|
||||
<P><IMG SRC="test.gif" WIDTH=574 HEIGHT=351></P>
|
||||
<P> </P>
|
||||
<P>More notes about the implementation of CppUnit can be found in README.HTML.</P>
|
||||
<P> </P>
|
||||
<P> </P></BODY>
|
||||
</HTML>
|
15
contrib/libpoco/CppUnit/doc/license.htm
Normal file
15
contrib/libpoco/CppUnit/doc/license.htm
Normal file
@ -0,0 +1,15 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
|
||||
<META NAME="Generator" CONTENT="Microsoft Word 97">
|
||||
<TITLE>License Agreement</TITLE>
|
||||
<META NAME="Template" CONTENT="C:\Program Files\MSOffice\Office\html.dot">
|
||||
</HEAD>
|
||||
<BODY LINK="#0000ff" VLINK="#800080">
|
||||
|
||||
<P>Permission to reproduce and create derivative works from the Software ("Software Derivative Works") is hereby granted to you under the copyright of Michael Feathers. Michael Feathers also grants you the right to distribute the Software and Software Derivative Works. </P>
|
||||
<P>Michael Feathers licenses the Software to you on an "AS IS" basis, without warranty of any kind. Michael Feathers HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES OR CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, NON INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using the Software and assume all risks associated with the use and distribution of this Software, including but not limited to the risks of program errors, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. MICHAEL FEATHERS WILL NOT BE LIABLE FOR ANY DIRECT DAMAGES OR FOR ANY SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF MICHAEL FEATHERS HAD BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Michael Feathers will not be liable for the loss of, or damage to, your records or data, or any damages claimed by you based on a third party claim. </P>
|
||||
<P>You agree to distribute the Software and any Software Derivatives under a license agreement that: 1) is sufficient to notify all licensees of the Software and Software Derivatives that Michael Feathers assumes no liability for any claim that may arise regarding the Software or Software Derivatives, and 2) that disclaims all warranties, both express and implied, from Michael Feathers regarding the Software and Software Derivatives. (If you include this Agreement with any distribution of the Software and Software Derivatives you will have meet this requirement). You agree that you will not delete any copyright notices in the Software. </P>
|
||||
<P>This Agreement is the exclusive statement of your rights in the Software as provided by Michael Feathers. Except for the licenses granted to you in the second paragraph above, no other licenses are granted hereunder, by estoppel, implication or otherwise. <BR>
|
||||
</P></BODY>
|
||||
</HTML>
|
BIN
contrib/libpoco/CppUnit/doc/test.gif
Normal file
BIN
contrib/libpoco/CppUnit/doc/test.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
60
contrib/libpoco/CppUnit/include/CppUnit/CppUnit.h
Normal file
60
contrib/libpoco/CppUnit/include/CppUnit/CppUnit.h
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// CppUnit.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/CppUnit.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_CppUnit_INCLUDED
|
||||
#define CppUnit_CppUnit_INCLUDED
|
||||
|
||||
|
||||
//
|
||||
// Ensure that POCO_DLL is default unless POCO_STATIC is defined
|
||||
//
|
||||
#if defined(_WIN32) && defined(_DLL)
|
||||
#if !defined(POCO_DLL) && !defined(POCO_STATIC)
|
||||
#define POCO_DLL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// The following block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the CppUnit_EXPORTS
|
||||
// symbol defined on the command line. this symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// CppUnit_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
#if defined(CppUnit_EXPORTS)
|
||||
#define CppUnit_API __declspec(dllexport)
|
||||
#else
|
||||
#define CppUnit_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(CppUnit_API)
|
||||
#if defined (__GNUC__) && (__GNUC__ >= 4)
|
||||
#define CppUnit_API __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define CppUnit_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Turn off some annoying warnings
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786) // identifier truncation warning
|
||||
#pragma warning(disable:4503) // decorated name length exceeded - mainly a problem with STLPort
|
||||
#pragma warning(disable:4018) // signed/unsigned comparison
|
||||
#pragma warning(disable:4284) // return type for operator -> is not UDT
|
||||
#pragma warning(disable:4251) // ... needs to have dll-interface warning
|
||||
#pragma warning(disable:4273)
|
||||
#pragma warning(disable:4275) // ... non dll-interface class used as base for dll-interface class
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CppUnit_CppUnit_INCLUDED
|
141
contrib/libpoco/CppUnit/include/CppUnit/CppUnitException.h
Normal file
141
contrib/libpoco/CppUnit/include/CppUnit/CppUnitException.h
Normal file
@ -0,0 +1,141 @@
|
||||
//
|
||||
// CppUnitException.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/CppUnitException.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_CppUnitException_INCLUDED
|
||||
#define CppUnit_CppUnitException_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class CppUnit_API CppUnitException: public std::exception
|
||||
/// CppUnitException is an exception that serves
|
||||
/// descriptive strings through its what() method
|
||||
{
|
||||
public:
|
||||
CppUnitException(const std::string& message = "",
|
||||
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
|
||||
CppUnitException(const std::string& message,
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
const std::string& fileName);
|
||||
CppUnitException(const std::string& message,
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
long data2lineNumber,
|
||||
const std::string& fileName);
|
||||
CppUnitException(const CppUnitException& other);
|
||||
virtual ~CppUnitException() throw();
|
||||
|
||||
CppUnitException& operator = (const CppUnitException& other);
|
||||
|
||||
const char* what() const throw ();
|
||||
|
||||
long lineNumber() const;
|
||||
long data1LineNumber() const;
|
||||
long data2LineNumber() const;
|
||||
const std::string& fileName() const;
|
||||
|
||||
static const std::string CPPUNIT_UNKNOWNFILENAME;
|
||||
static const int CPPUNIT_UNKNOWNLINENUMBER;
|
||||
|
||||
private:
|
||||
std::string _message;
|
||||
long _lineNumber;
|
||||
long _data1lineNumber;
|
||||
long _data2lineNumber;
|
||||
std::string _fileName;
|
||||
};
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException(const CppUnitException& other): exception (other)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(data2lineNumber), _fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::~CppUnitException () throw()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException& CppUnitException::operator = (const CppUnitException& other)
|
||||
{
|
||||
exception::operator= (other);
|
||||
|
||||
if (&other != this)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline const char* CppUnitException::what() const throw ()
|
||||
{
|
||||
return _message.c_str();
|
||||
}
|
||||
|
||||
|
||||
inline long CppUnitException::lineNumber() const
|
||||
{
|
||||
return _lineNumber;
|
||||
}
|
||||
|
||||
|
||||
inline long CppUnitException::data1LineNumber() const
|
||||
{
|
||||
return _data1lineNumber;
|
||||
}
|
||||
|
||||
|
||||
inline long CppUnitException::data2LineNumber() const
|
||||
{
|
||||
return _data2lineNumber;
|
||||
}
|
||||
|
||||
|
||||
// The file in which the error occurred
|
||||
inline const std::string& CppUnitException::fileName() const
|
||||
{
|
||||
return _fileName;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_CppUnitException_INCLUDED
|
19
contrib/libpoco/CppUnit/include/CppUnit/Guards.h
Normal file
19
contrib/libpoco/CppUnit/include/CppUnit/Guards.h
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// Guards.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/Guards.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_Guards_INCLUDED
|
||||
#define CppUnit_Guards_INCLUDED
|
||||
|
||||
|
||||
// Prevent copy construction and assignment for a class
|
||||
#define REFERENCEOBJECT(className) \
|
||||
private: \
|
||||
className(const className& other); \
|
||||
className& operator = (const className& other);
|
||||
|
||||
|
||||
#endif // CppUnit_Guards_INCLUDED
|
105
contrib/libpoco/CppUnit/include/CppUnit/Orthodox.h
Normal file
105
contrib/libpoco/CppUnit/include/CppUnit/Orthodox.h
Normal file
@ -0,0 +1,105 @@
|
||||
//
|
||||
// Orthodox.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/Orthodox.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_Orthodox_INCLUDED
|
||||
#define CppUnit_Orthodox_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
/*
|
||||
* Orthodox performs a simple set of tests on an arbitary
|
||||
* class to make sure that it supports at least the
|
||||
* following operations:
|
||||
*
|
||||
* default construction - constructor
|
||||
* equality/inequality - operator== && operator!=
|
||||
* assignment - operator=
|
||||
* negation - operator!
|
||||
* safe passage - copy construction
|
||||
*
|
||||
* If operations for each of these are not declared
|
||||
* the template will not instantiate. If it does
|
||||
* instantiate, tests are performed to make sure
|
||||
* that the operations have correct semantics.
|
||||
*
|
||||
* Adding an orthodox test to a suite is very
|
||||
* easy:
|
||||
*
|
||||
* public: Test *suite () {
|
||||
* TestSuite *suiteOfTests = new TestSuite;
|
||||
* suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
|
||||
* suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
|
||||
* return suiteOfTests;
|
||||
* }
|
||||
*
|
||||
* Templated test cases be very useful when you are want to
|
||||
* make sure that a group of classes have the same form.
|
||||
*
|
||||
* see TestSuite
|
||||
*/
|
||||
template <class ClassUnderTest>
|
||||
class Orthodox: public TestCase
|
||||
{
|
||||
public:
|
||||
Orthodox(): TestCase("Orthodox")
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
ClassUnderTest call(ClassUnderTest object);
|
||||
void runTest ();
|
||||
};
|
||||
|
||||
|
||||
// Run an orthodoxy test
|
||||
template <class ClassUnderTest>
|
||||
void Orthodox<ClassUnderTest>::runTest()
|
||||
{
|
||||
// make sure we have a default constructor
|
||||
ClassUnderTest a, b, c;
|
||||
|
||||
// make sure we have an equality operator
|
||||
assert (a == b);
|
||||
|
||||
// check the inverse
|
||||
b.operator= (a.operator! ());
|
||||
assert (a != b);
|
||||
|
||||
// double inversion
|
||||
b = !!a;
|
||||
assert (a == b);
|
||||
|
||||
// invert again
|
||||
b = !a;
|
||||
|
||||
// check calls
|
||||
c = a;
|
||||
assert (c == call (a));
|
||||
|
||||
c = b;
|
||||
assert (c == call (b));
|
||||
}
|
||||
|
||||
|
||||
// Exercise a call
|
||||
template <class ClassUnderTest>
|
||||
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_Orthodox_INCLUDED
|
77
contrib/libpoco/CppUnit/include/CppUnit/RepeatedTest.h
Normal file
77
contrib/libpoco/CppUnit/include/CppUnit/RepeatedTest.h
Normal file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// RepeatedTest.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/RepeatedTest.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_RepeatedTest_INCLUDED
|
||||
#define CppUnit_RepeatedTest_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A decorator that runs a test repeatedly.
|
||||
* Does not assume ownership of the test it decorates
|
||||
*
|
||||
*/
|
||||
class CppUnit_API RepeatedTest: public TestDecorator
|
||||
{
|
||||
REFERENCEOBJECT (RepeatedTest)
|
||||
|
||||
public:
|
||||
RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat)
|
||||
{
|
||||
}
|
||||
|
||||
int countTestCases();
|
||||
std::string toString();
|
||||
void run(TestResult *result);
|
||||
|
||||
private:
|
||||
const int _timesRepeat;
|
||||
};
|
||||
|
||||
|
||||
// Counts the number of test cases that will be run by this test.
|
||||
inline RepeatedTest::countTestCases ()
|
||||
{
|
||||
return TestDecorator::countTestCases() * _timesRepeat;
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test instance.
|
||||
inline std::string RepeatedTest::toString()
|
||||
{
|
||||
return TestDecorator::toString() + " (repeated)";
|
||||
}
|
||||
|
||||
|
||||
// Runs a repeated test
|
||||
inline void RepeatedTest::run(TestResult *result)
|
||||
{
|
||||
for (int n = 0; n < _timesRepeat; n++)
|
||||
{
|
||||
if (result->shouldStop())
|
||||
break;
|
||||
|
||||
TestDecorator::run(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_RepeatedTest_INCLUDED
|
65
contrib/libpoco/CppUnit/include/CppUnit/Test.h
Normal file
65
contrib/libpoco/CppUnit/include/CppUnit/Test.h
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// Test.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/Test.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_Test_INCLUDED
|
||||
#define CppUnit_Test_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A Test can be run and collect its results.
|
||||
* See TestResult.
|
||||
*
|
||||
*/
|
||||
class CppUnit_API Test
|
||||
{
|
||||
public:
|
||||
virtual ~Test() = 0;
|
||||
virtual void run(TestResult* result) = 0;
|
||||
virtual int countTestCases() = 0;
|
||||
virtual std::string toString() = 0;
|
||||
};
|
||||
|
||||
|
||||
inline Test::~Test()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Runs a test and collects its result in a TestResult instance.
|
||||
inline void Test::run(TestResult *result)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Counts the number of test cases that will be run by this test.
|
||||
inline int Test::countTestCases()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test instance.
|
||||
inline std::string Test::toString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_Test_INCLUDED
|
95
contrib/libpoco/CppUnit/include/CppUnit/TestCaller.h
Normal file
95
contrib/libpoco/CppUnit/include/CppUnit/TestCaller.h
Normal file
@ -0,0 +1,95 @@
|
||||
//
|
||||
// TestCaller.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestCaller.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestCaller_INCLUDED
|
||||
#define CppUnit_TestCaller_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "Guards.h"
|
||||
#include "TestCase.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
/*
|
||||
* A test caller provides access to a test case method
|
||||
* on a test case class. Test callers are useful when
|
||||
* you want to run an individual test or add it to a
|
||||
* suite.
|
||||
*
|
||||
* Here is an example:
|
||||
*
|
||||
* class MathTest : public TestCase {
|
||||
* ...
|
||||
* public:
|
||||
* void setUp ();
|
||||
* void tearDown ();
|
||||
*
|
||||
* void testAdd ();
|
||||
* void testSubtract ();
|
||||
* };
|
||||
*
|
||||
* Test *MathTest::suite () {
|
||||
* TestSuite *suite = new TestSuite;
|
||||
*
|
||||
* suite->addTest (new TestCaller<MathTest> ("testAdd", testAdd));
|
||||
* return suite;
|
||||
* }
|
||||
*
|
||||
* You can use a TestCaller to bind any test method on a TestCase
|
||||
* class, as long as it returns accepts void and returns void.
|
||||
*
|
||||
* See TestCase
|
||||
*/
|
||||
template <class Fixture>
|
||||
class TestCaller: public TestCase
|
||||
{
|
||||
REFERENCEOBJECT (TestCaller)
|
||||
|
||||
typedef void (Fixture::*TestMethod)();
|
||||
|
||||
public:
|
||||
TestCaller(const std::string& name, TestMethod test):
|
||||
TestCase(name),
|
||||
_test(test),
|
||||
_fixture(new Fixture(name))
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void runTest()
|
||||
{
|
||||
(_fixture.get()->*_test)();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
_fixture.get()->setUp();
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
_fixture.get()->tearDown();
|
||||
}
|
||||
|
||||
private:
|
||||
TestMethod _test;
|
||||
std::unique_ptr<Fixture> _fixture;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#define CppUnit_addTest(suite, cls, mth) \
|
||||
suite->addTest(new CppUnit::TestCaller<cls>(#mth, &cls::mth))
|
||||
|
||||
|
||||
#endif // CppUnit_TestCaller_INCLUDED
|
257
contrib/libpoco/CppUnit/include/CppUnit/TestCase.h
Normal file
257
contrib/libpoco/CppUnit/include/CppUnit/TestCase.h
Normal file
@ -0,0 +1,257 @@
|
||||
//
|
||||
// TestCase.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestCase.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestCase_INCLUDED
|
||||
#define CppUnit_TestCase_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/Test.h"
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A test case defines the fixture to run multiple tests. To define a test case
|
||||
* 1) implement a subclass of TestCase
|
||||
* 2) define instance variables that store the state of the fixture
|
||||
* 3) initialize the fixture state by overriding setUp
|
||||
* 4) clean-up after a test by overriding tearDown.
|
||||
*
|
||||
* Each test runs in its own fixture so there
|
||||
* can be no side effects among test runs.
|
||||
* Here is an example:
|
||||
*
|
||||
* class MathTest : public TestCase {
|
||||
* protected: int m_value1;
|
||||
* protected: int m_value2;
|
||||
*
|
||||
* public: MathTest (std::string name)
|
||||
* : TestCase (name) {
|
||||
* }
|
||||
*
|
||||
* protected: void setUp () {
|
||||
* m_value1 = 2;
|
||||
* m_value2 = 3;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* For each test implement a method which interacts
|
||||
* with the fixture. Verify the expected results with assertions specified
|
||||
* by calling assert on the expression you want to test:
|
||||
*
|
||||
* protected: void testAdd () {
|
||||
* int result = value1 + value2;
|
||||
* assert (result == 5);
|
||||
* }
|
||||
*
|
||||
* Once the methods are defined you can run them. To do this, use
|
||||
* a TestCaller.
|
||||
*
|
||||
* Test *test = new TestCaller<MathTest>("testAdd", MathTest::testAdd);
|
||||
* test->run ();
|
||||
*
|
||||
*
|
||||
* The tests to be run can be collected into a TestSuite. CppUnit provides
|
||||
* different test runners which can run a test suite and collect the results.
|
||||
* The test runners expect a static method suite as the entry
|
||||
* point to get a test to run.
|
||||
*
|
||||
* public: static MathTest::suite () {
|
||||
* TestSuite *suiteOfTests = new TestSuite;
|
||||
* suiteOfTests->addTest(new TestCaller<MathTest>("testAdd", testAdd));
|
||||
* suiteOfTests->addTest(new TestCaller<MathTest>("testDivideByZero", testDivideByZero));
|
||||
* return suiteOfTests;
|
||||
* }
|
||||
*
|
||||
* Note that the caller of suite assumes lifetime control
|
||||
* for the returned suite.
|
||||
*
|
||||
* see TestResult, TestSuite and TestCaller
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestCase: public Test
|
||||
{
|
||||
REFERENCEOBJECT (TestCase)
|
||||
|
||||
public:
|
||||
TestCase(const std::string& Name);
|
||||
~TestCase();
|
||||
|
||||
virtual void run(TestResult* result);
|
||||
virtual TestResult* run();
|
||||
virtual int countTestCases();
|
||||
const std::string& name() const;
|
||||
std::string toString();
|
||||
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
protected:
|
||||
virtual void runTest();
|
||||
TestResult* defaultResult();
|
||||
|
||||
void assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void loop1assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long dataLineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void loop2assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data1LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(long expected,
|
||||
long actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(double expected,
|
||||
double actual,
|
||||
double delta,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const std::string& expected,
|
||||
const std::string& actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const void* expected,
|
||||
const void* actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
std::string notEqualsMessage(long expected, long actual);
|
||||
std::string notEqualsMessage(double expected, double actual);
|
||||
std::string notEqualsMessage(const void* expected, const void* actual);
|
||||
std::string notEqualsMessage(const std::string& expected, const std::string& actual);
|
||||
|
||||
void assertNotNull(const void* pointer,
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertNull(const void* pointer,
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void fail(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void warn(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
};
|
||||
|
||||
|
||||
// Constructs a test case
|
||||
inline TestCase::TestCase(const std::string& name): _name (name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Destructs a test case
|
||||
inline TestCase::~TestCase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Returns a count of all the tests executed
|
||||
inline int TestCase::countTestCases()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test case
|
||||
inline const std::string& TestCase::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
// A hook for fixture set up
|
||||
inline void TestCase::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// A hook for fixture tear down
|
||||
inline void TestCase::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test case instance
|
||||
inline std::string TestCase::toString()
|
||||
{
|
||||
const std::type_info& thisClass = typeid(*this);
|
||||
return std::string(thisClass.name()) + "." + name();
|
||||
}
|
||||
|
||||
|
||||
// A set of macros which allow us to get the line number
|
||||
// and file name at the point of an error.
|
||||
// Just goes to show that preprocessors do have some
|
||||
// redeeming qualities.
|
||||
#undef assert
|
||||
#define assert(condition) \
|
||||
(this->assertImplementation((condition), (#condition), __LINE__, __FILE__))
|
||||
|
||||
#define loop_1_assert(data1line, condition) \
|
||||
(this->loop1assertImplementation((condition), (#condition), __LINE__, data1line, __FILE__))
|
||||
|
||||
#define loop_2_assert(data1line, data2line, condition) \
|
||||
(this->loop2assertImplementation((condition), (#condition), __LINE__, data1line, data2line, __FILE__))
|
||||
|
||||
#define assertEqualDelta(expected, actual, delta) \
|
||||
(this->assertEquals((expected), (actual), (delta), __LINE__, __FILE__))
|
||||
|
||||
#define assertEqual(expected, actual) \
|
||||
(this->assertEquals((expected), (actual), __LINE__, __FILE__))
|
||||
|
||||
#define assertNullPtr(ptr) \
|
||||
(this->assertNull((ptr), #ptr, __LINE__, __FILE__))
|
||||
|
||||
#define assertNotNullPtr(ptr) \
|
||||
(this->assertNotNull((ptr), #ptr, __LINE__, __FILE__))
|
||||
|
||||
#define failmsg(msg) \
|
||||
(this->fail(msg, __LINE__, __FILE__))
|
||||
|
||||
#define warnmsg(msg) \
|
||||
(this->fail(msg, __LINE__, __FILE__))
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestCase_INCLUDED
|
52
contrib/libpoco/CppUnit/include/CppUnit/TestDecorator.h
Normal file
52
contrib/libpoco/CppUnit/include/CppUnit/TestDecorator.h
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// TestDecorator.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestDecorator.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestDecorator_INCLUDED
|
||||
#define CppUnit_TestDecorator_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/Test.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A Decorator for Tests
|
||||
*
|
||||
* Does not assume ownership of the test it decorates
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestDecorator: public Test
|
||||
{
|
||||
REFERENCEOBJECT(TestDecorator)
|
||||
|
||||
public:
|
||||
TestDecorator(Test* test);
|
||||
|
||||
virtual ~TestDecorator();
|
||||
|
||||
int countTestCases();
|
||||
|
||||
void run(TestResult* result);
|
||||
|
||||
std::string toString();
|
||||
|
||||
protected:
|
||||
Test* _test;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestDecorator_INCLUDED
|
86
contrib/libpoco/CppUnit/include/CppUnit/TestFailure.h
Normal file
86
contrib/libpoco/CppUnit/include/CppUnit/TestFailure.h
Normal file
@ -0,0 +1,86 @@
|
||||
//
|
||||
// TestFailure.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestFailure.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestFailure_INCLUDED
|
||||
#define CppUnit_TestFailure_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
|
||||
/*
|
||||
* A TestFailure collects a failed test together with
|
||||
* the caught exception.
|
||||
*
|
||||
* TestFailure assumes lifetime control for any exception
|
||||
* passed to it. The lifetime of tests is handled by
|
||||
* their TestSuite (if they have been added to one) or
|
||||
* whomever creates them.
|
||||
*
|
||||
* see TestResult
|
||||
* see TestSuite
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestFailure
|
||||
{
|
||||
REFERENCEOBJECT (TestFailure)
|
||||
|
||||
public:
|
||||
TestFailure(Test* failedTest, CppUnitException* thrownException);
|
||||
~TestFailure();
|
||||
|
||||
Test* failedTest();
|
||||
CppUnitException* thrownException();
|
||||
std::string toString();
|
||||
|
||||
protected:
|
||||
Test* _failedTest;
|
||||
CppUnitException *_thrownException;
|
||||
};
|
||||
|
||||
|
||||
// Constructs a TestFailure with the given test and exception.
|
||||
inline TestFailure::TestFailure(Test* failedTest, CppUnitException* thrownException): _failedTest(failedTest), _thrownException(thrownException)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Deletes the owned exception.
|
||||
inline TestFailure::~TestFailure()
|
||||
{
|
||||
delete _thrownException;
|
||||
}
|
||||
|
||||
|
||||
// Gets the failed test.
|
||||
inline Test* TestFailure::failedTest()
|
||||
{
|
||||
return _failedTest;
|
||||
}
|
||||
|
||||
|
||||
// Gets the thrown exception.
|
||||
inline CppUnitException* TestFailure::thrownException()
|
||||
{
|
||||
return _thrownException;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestFailure_INCLUDED
|
||||
|
||||
|
231
contrib/libpoco/CppUnit/include/CppUnit/TestResult.h
Normal file
231
contrib/libpoco/CppUnit/include/CppUnit/TestResult.h
Normal file
@ -0,0 +1,231 @@
|
||||
//
|
||||
// TestResult.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestResult.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestResult_INCLUDED
|
||||
#define CppUnit_TestResult_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/TestFailure.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class CppUnitException;
|
||||
class Test;
|
||||
|
||||
|
||||
/*
|
||||
* A TestResult collects the results of executing a test case. It is an
|
||||
* instance of the Collecting Parameter pattern.
|
||||
*
|
||||
* The test framework distinguishes between failures and errors.
|
||||
* A failure is anticipated and checked for with assertions. Errors are
|
||||
* unanticipated problems signified by exceptions that are not generated
|
||||
* by the framework.
|
||||
*
|
||||
* TestResult supplies a template method 'setSynchronizationObject ()'
|
||||
* so that subclasses can provide mutual exclusion in the face of multiple
|
||||
* threads. This can be useful when tests execute in one thread and
|
||||
* they fill a subclass of TestResult which effects change in another
|
||||
* thread. To have mutual exclusion, override setSynchronizationObject ()
|
||||
* and make sure that you create an instance of ExclusiveZone at the
|
||||
* beginning of each method.
|
||||
*
|
||||
* see Test
|
||||
*/
|
||||
class CppUnit_API TestResult
|
||||
{
|
||||
REFERENCEOBJECT (TestResult)
|
||||
|
||||
public:
|
||||
TestResult();
|
||||
virtual ~TestResult();
|
||||
|
||||
virtual void addError(Test* test, CppUnitException* e);
|
||||
virtual void addFailure(Test* test, CppUnitException* e);
|
||||
virtual void startTest(Test* test);
|
||||
virtual void endTest(Test* test);
|
||||
virtual int runTests();
|
||||
virtual int testErrors();
|
||||
virtual int testFailures();
|
||||
virtual bool wasSuccessful();
|
||||
virtual bool shouldStop();
|
||||
virtual void stop();
|
||||
|
||||
virtual std::vector<TestFailure*>& errors();
|
||||
virtual std::vector<TestFailure*>& failures();
|
||||
|
||||
class SynchronizationObject
|
||||
{
|
||||
public:
|
||||
SynchronizationObject()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~SynchronizationObject()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void lock()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void unlock()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class ExclusiveZone
|
||||
{
|
||||
SynchronizationObject* m_syncObject;
|
||||
|
||||
public:
|
||||
ExclusiveZone(SynchronizationObject* syncObject): m_syncObject(syncObject)
|
||||
{
|
||||
m_syncObject->lock();
|
||||
}
|
||||
|
||||
~ExclusiveZone()
|
||||
{
|
||||
m_syncObject->unlock();
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void setSynchronizationObject(SynchronizationObject* syncObject);
|
||||
|
||||
std::vector<TestFailure*> _errors;
|
||||
std::vector<TestFailure*> _failures;
|
||||
int _runTests;
|
||||
bool _stop;
|
||||
SynchronizationObject* _syncObject;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Construct a TestResult
|
||||
inline TestResult::TestResult(): _syncObject(new SynchronizationObject())
|
||||
{
|
||||
_runTests = 0;
|
||||
_stop = false;
|
||||
}
|
||||
|
||||
|
||||
// Adds an error to the list of errors. The passed in exception
|
||||
// caused the error
|
||||
inline void TestResult::addError(Test* test, CppUnitException* e)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_errors.push_back(new TestFailure(test, e));
|
||||
}
|
||||
|
||||
|
||||
// Adds a failure to the list of failures. The passed in exception
|
||||
// caused the failure.
|
||||
inline void TestResult::addFailure(Test* test, CppUnitException* e)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_failures.push_back(new TestFailure(test, e));
|
||||
}
|
||||
|
||||
|
||||
// Informs the result that a test will be started.
|
||||
inline void TestResult::startTest(Test* test)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_runTests++;
|
||||
}
|
||||
|
||||
|
||||
// Informs the result that a test was completed.
|
||||
inline void TestResult::endTest(Test* test)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
}
|
||||
|
||||
|
||||
// Gets the number of run tests.
|
||||
inline int TestResult::runTests()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _runTests;
|
||||
}
|
||||
|
||||
|
||||
// Gets the number of detected errors.
|
||||
inline int TestResult::testErrors()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return (int) _errors.size();
|
||||
}
|
||||
|
||||
|
||||
// Gets the number of detected failures.
|
||||
inline int TestResult::testFailures()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return (int) _failures.size();
|
||||
}
|
||||
|
||||
|
||||
// Returns whether the entire test was successful or not.
|
||||
inline bool TestResult::wasSuccessful()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _failures.size() == 0 && _errors.size () == 0;
|
||||
}
|
||||
|
||||
|
||||
// Returns a std::vector of the errors.
|
||||
inline std::vector<TestFailure*>& TestResult::errors()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _errors;
|
||||
}
|
||||
|
||||
|
||||
// Returns a std::vector of the failures.
|
||||
inline std::vector<TestFailure*>& TestResult::failures()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _failures;
|
||||
}
|
||||
|
||||
|
||||
// Returns whether testing should be stopped
|
||||
inline bool TestResult::shouldStop()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _stop;
|
||||
}
|
||||
|
||||
|
||||
// Stop testing
|
||||
inline void TestResult::stop()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
// Accept a new synchronization object for protection of this instance
|
||||
// TestResult assumes ownership of the object
|
||||
inline void TestResult::setSynchronizationObject(SynchronizationObject* syncObject)
|
||||
{
|
||||
delete _syncObject;
|
||||
_syncObject = syncObject;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestResult_INCLUDED
|
103
contrib/libpoco/CppUnit/include/CppUnit/TestRunner.h
Normal file
103
contrib/libpoco/CppUnit/include/CppUnit/TestRunner.h
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// TestRunner.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestRunner.h#2 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestRunner_INCLUDED
|
||||
#define CppUnit_TestRunner_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#if defined(POCO_VXWORKS)
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
|
||||
/*
|
||||
* A command line based tool to run tests.
|
||||
* TestRunner expects as its only argument the name of a TestCase class.
|
||||
* TestRunner prints out a trace as the tests are executed followed by a
|
||||
* summary at the end.
|
||||
*
|
||||
* You can add to the tests that the TestRunner knows about by
|
||||
* making additional calls to "addTest (...)" in main.
|
||||
*
|
||||
* Here is the synopsis:
|
||||
*
|
||||
* TestRunner [-all] [-print] [-wait] ExampleTestCase
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestRunner
|
||||
{
|
||||
typedef std::pair<std::string, Test*> Mapping;
|
||||
typedef std::vector<Mapping> Mappings;
|
||||
|
||||
public:
|
||||
TestRunner();
|
||||
TestRunner(std::ostream& ostr);
|
||||
~TestRunner();
|
||||
|
||||
bool run(const std::vector<std::string>& args);
|
||||
void addTest(const std::string& name, Test* test);
|
||||
|
||||
protected:
|
||||
bool run(Test* test);
|
||||
void printBanner();
|
||||
void print(const std::string& name, Test* pTest, int indent);
|
||||
Test* find(const std::string& name, Test* pTest, const std::string& testName);
|
||||
|
||||
private:
|
||||
std::ostream& _ostr;
|
||||
Mappings _mappings;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#if defined(POCO_VXWORKS)
|
||||
#define CppUnitMain(testCase) \
|
||||
int testCase##Runner(const char* arg0, ...) \
|
||||
{ \
|
||||
std::vector<std::string> args; \
|
||||
args.push_back(#testCase "Runner"); \
|
||||
args.push_back(std::string(arg0)); \
|
||||
va_list vargs; \
|
||||
va_start(vargs, arg0); \
|
||||
const char* arg = va_arg(vargs, const char*); \
|
||||
while (arg) \
|
||||
{ \
|
||||
args.push_back(std::string(arg)); \
|
||||
arg = va_arg(vargs, const char*); \
|
||||
} \
|
||||
va_end(vargs); \
|
||||
CppUnit::TestRunner runner; \
|
||||
runner.addTest(#testCase, testCase::suite()); \
|
||||
return runner.run(args) ? 0 : 1; \
|
||||
}
|
||||
#else
|
||||
#define CppUnitMain(testCase) \
|
||||
int main(int ac, char **av) \
|
||||
{ \
|
||||
std::vector<std::string> args; \
|
||||
for (int i = 0; i < ac; ++i) \
|
||||
args.push_back(std::string(av[i])); \
|
||||
CppUnit::TestRunner runner; \
|
||||
runner.addTest(#testCase, testCase::suite()); \
|
||||
return runner.run(args) ? 0 : 1; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CppUnit_TestRunner_INCLUDED
|
57
contrib/libpoco/CppUnit/include/CppUnit/TestSetup.h
Normal file
57
contrib/libpoco/CppUnit/include/CppUnit/TestSetup.h
Normal file
@ -0,0 +1,57 @@
|
||||
//
|
||||
// TestSetup.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestSetup.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestSetup_INCLUDED
|
||||
#define CppUnit_TestSetup_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
|
||||
class CppUnit_API TestSetup: public TestDecorator
|
||||
{
|
||||
REFERENCEOBJECT (TestSetup)
|
||||
|
||||
public:
|
||||
TestSetup(Test* test): TestDecorator(test)
|
||||
{
|
||||
}
|
||||
|
||||
void run(TestResult* result);
|
||||
|
||||
protected:
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline void TestSetup::run(TestResult* result)
|
||||
{
|
||||
setUp();
|
||||
TestDecorator::run(result);
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestSetup_INCLUDED
|
98
contrib/libpoco/CppUnit/include/CppUnit/TestSuite.h
Normal file
98
contrib/libpoco/CppUnit/include/CppUnit/TestSuite.h
Normal file
@ -0,0 +1,98 @@
|
||||
//
|
||||
// TestSuite.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TestSuite.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestSuite_INCLUDED
|
||||
#define CppUnit_TestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/Test.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A TestSuite is a Composite of Tests.
|
||||
* It runs a collection of test cases. Here is an example.
|
||||
*
|
||||
* TestSuite *suite= new TestSuite();
|
||||
* suite->addTest(new TestCaller<MathTest> ("testAdd", testAdd));
|
||||
* suite->addTest(new TestCaller<MathTest> ("testDivideByZero", testDivideByZero));
|
||||
*
|
||||
* Note that TestSuites assume lifetime
|
||||
* control for any tests added to them.
|
||||
*
|
||||
* see Test and TestCaller
|
||||
*/
|
||||
class CppUnit_API TestSuite: public Test
|
||||
{
|
||||
REFERENCEOBJECT (TestSuite)
|
||||
|
||||
public:
|
||||
TestSuite(const std::string& name = "");
|
||||
~TestSuite();
|
||||
|
||||
void run(TestResult* result);
|
||||
int countTestCases();
|
||||
void addTest(Test* test);
|
||||
std::string toString();
|
||||
|
||||
virtual void deleteContents();
|
||||
|
||||
const std::vector<Test*> tests() const;
|
||||
|
||||
private:
|
||||
std::vector<Test*> _tests;
|
||||
const std::string _name;
|
||||
};
|
||||
|
||||
|
||||
// Default constructor
|
||||
inline TestSuite::TestSuite(const std::string& name): _name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
inline TestSuite::~TestSuite()
|
||||
{
|
||||
deleteContents();
|
||||
}
|
||||
|
||||
|
||||
// Adds a test to the suite.
|
||||
inline void TestSuite::addTest(Test* test)
|
||||
{
|
||||
_tests.push_back(test);
|
||||
}
|
||||
|
||||
|
||||
// Returns a std::string representation of the test suite.
|
||||
inline std::string TestSuite::toString()
|
||||
{
|
||||
return "suite " + _name;
|
||||
}
|
||||
|
||||
|
||||
// Returns all tests
|
||||
inline const std::vector<Test*> TestSuite::tests() const
|
||||
{
|
||||
return _tests;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestSuite_INCLUDED
|
56
contrib/libpoco/CppUnit/include/CppUnit/TextTestResult.h
Normal file
56
contrib/libpoco/CppUnit/include/CppUnit/TextTestResult.h
Normal file
@ -0,0 +1,56 @@
|
||||
//
|
||||
// TextTestResult.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/TextTestResult.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TextTestResult_INCLUDED
|
||||
#define CppUnit_TextTestResult_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/TestResult.h"
|
||||
#include <set>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class CppUnit_API TextTestResult: public TestResult
|
||||
{
|
||||
public:
|
||||
TextTestResult();
|
||||
TextTestResult(std::ostream& ostr);
|
||||
|
||||
virtual void addError(Test* test, CppUnitException* e);
|
||||
virtual void addFailure(Test* test, CppUnitException* e);
|
||||
virtual void startTest(Test* test);
|
||||
virtual void print(std::ostream& stream);
|
||||
virtual void printErrors(std::ostream& stream);
|
||||
virtual void printFailures(std::ostream& stream);
|
||||
virtual void printHeader(std::ostream& stream);
|
||||
|
||||
protected:
|
||||
std::string shortName(const std::string& testName);
|
||||
void setup();
|
||||
|
||||
private:
|
||||
std::ostream& _ostr;
|
||||
std::set<std::string> _ignored;
|
||||
};
|
||||
|
||||
|
||||
/* insertion operator for easy output */
|
||||
inline std::ostream& operator<< (std::ostream& stream, TextTestResult& result)
|
||||
{
|
||||
result.print(stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TextTestResult_INCLUDED
|
73
contrib/libpoco/CppUnit/include/CppUnit/estring.h
Normal file
73
contrib/libpoco/CppUnit/include/CppUnit/estring.h
Normal file
@ -0,0 +1,73 @@
|
||||
//
|
||||
// estring.h
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/include/CppUnit/estring.h#1 $
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_estring_INCLUDED
|
||||
#define CppUnit_estring_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Create a std::string from a const char pointer
|
||||
inline std::string estring(const char *cstring)
|
||||
{
|
||||
return std::string(cstring);
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from a std::string (for uniformities' sake)
|
||||
inline std::string estring(std::string& expandedString)
|
||||
{
|
||||
return expandedString;
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from an int
|
||||
inline std::string estring(int number)
|
||||
{
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%d", number);
|
||||
return std::string (buffer);
|
||||
}
|
||||
|
||||
|
||||
// Create a string from a long
|
||||
inline std::string estring(long number)
|
||||
{
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%ld", number);
|
||||
return std::string (buffer);
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from a double
|
||||
inline std::string estring(double number)
|
||||
{
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%lf", number);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from a double
|
||||
inline std::string estring(const void* ptr)
|
||||
{
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%p", ptr);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_estring_INCLUDED
|
18
contrib/libpoco/CppUnit/src/CppUnitException.cpp
Normal file
18
contrib/libpoco/CppUnit/src/CppUnitException.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// CppUnitException.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/CppUnitException.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
const std::string CppUnitException::CPPUNIT_UNKNOWNFILENAME = "<unknown>";
|
||||
const int CppUnitException::CPPUNIT_UNKNOWNLINENUMBER = -1;
|
||||
|
||||
|
||||
} // namespace CppUnit
|
189
contrib/libpoco/CppUnit/src/TestCase.cpp
Normal file
189
contrib/libpoco/CppUnit/src/TestCase.cpp
Normal file
@ -0,0 +1,189 @@
|
||||
//
|
||||
// TestCase.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TestCase.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <math.h>
|
||||
#include "CppUnit/TestCase.h"
|
||||
#include "CppUnit/TestResult.h"
|
||||
#include "CppUnit/estring.h"
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Create a default TestResult
|
||||
TestResult* TestCase::defaultResult()
|
||||
{
|
||||
return new TestResult;
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed general assertion
|
||||
void TestCase::assertImplementation(bool condition, const std::string& conditionExpression, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (!condition)
|
||||
throw CppUnitException(conditionExpression, lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::loop1assertImplementation(bool condition, const std::string& conditionExpression, long lineNumber, long data1lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (!condition)
|
||||
throw CppUnitException(conditionExpression, lineNumber, data1lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::loop2assertImplementation(bool condition, const std::string& conditionExpression, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (!condition)
|
||||
throw CppUnitException(conditionExpression, lineNumber, data1lineNumber, data2lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(long expected, long actual, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (expected != actual)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(double expected, double actual, double delta, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (fabs(expected - actual) > delta)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(const void* expected, const void* actual, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (expected != actual)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
// Check for a failed equality assertion
|
||||
void TestCase::assertEquals(const std::string& expected, const std::string& actual, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (expected != actual)
|
||||
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::assertNotNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (pointer == NULL)
|
||||
throw CppUnitException(pointerExpression + " must not be NULL", lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::assertNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
if (pointer != NULL)
|
||||
throw CppUnitException(pointerExpression + " must be NULL", lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::fail(const std::string& message, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
throw CppUnitException(std::string("fail: ") + message, lineNumber, fileName);
|
||||
}
|
||||
|
||||
|
||||
void TestCase::warn(const std::string& message, long lineNumber, const std::string& fileName)
|
||||
{
|
||||
std::cout << "Warning [" << fileName << ':' << lineNumber << "]: " << message << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// Run the test and catch any exceptions that are triggered by it
|
||||
void TestCase::run(TestResult *result)
|
||||
{
|
||||
result->startTest(this);
|
||||
|
||||
setUp();
|
||||
try
|
||||
{
|
||||
runTest();
|
||||
}
|
||||
catch (CppUnitException& e)
|
||||
{
|
||||
CppUnitException* copy = new CppUnitException(e);
|
||||
result->addFailure(this, copy);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string msg(typeid(e).name());
|
||||
msg.append(": ");
|
||||
msg.append(e.what());
|
||||
result->addError(this, new CppUnitException(msg));
|
||||
|
||||
}
|
||||
#if !defined(_WIN32)
|
||||
catch (...)
|
||||
{
|
||||
CppUnitException *e = new CppUnitException ("unknown exception");
|
||||
result->addError (this, e);
|
||||
}
|
||||
#endif
|
||||
tearDown ();
|
||||
result->endTest(this);
|
||||
}
|
||||
|
||||
|
||||
// A default run method
|
||||
TestResult* TestCase::run()
|
||||
{
|
||||
TestResult* result = defaultResult();
|
||||
|
||||
run(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// All the work for runTest is deferred to subclasses
|
||||
void TestCase::runTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(long expected, long actual)
|
||||
{
|
||||
return "expected: " + estring(expected) + " but was: " + estring(actual);
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(double expected, double actual)
|
||||
{
|
||||
return "expected: " + estring(expected) + " but was: " + estring(actual);
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(const void* expected, const void* actual)
|
||||
{
|
||||
return "expected: " + estring(expected) + " but was: " + estring(actual);
|
||||
}
|
||||
|
||||
|
||||
// Build a message about a failed equality check
|
||||
std::string TestCase::notEqualsMessage(const std::string& expected, const std::string& actual)
|
||||
{
|
||||
return "expected: \"" + expected + "\" but was: \"" + actual + "\"";
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
43
contrib/libpoco/CppUnit/src/TestDecorator.cpp
Normal file
43
contrib/libpoco/CppUnit/src/TestDecorator.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
//
|
||||
// TestDecorator.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TestDecorator.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
TestDecorator::TestDecorator(Test* test)
|
||||
{
|
||||
_test = test;
|
||||
}
|
||||
|
||||
|
||||
TestDecorator::~TestDecorator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int TestDecorator::countTestCases()
|
||||
{
|
||||
return _test->countTestCases();
|
||||
}
|
||||
|
||||
|
||||
void TestDecorator::run(TestResult* result)
|
||||
{
|
||||
_test->run(result);
|
||||
}
|
||||
|
||||
|
||||
std::string TestDecorator::toString()
|
||||
{
|
||||
return _test->toString();
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
22
contrib/libpoco/CppUnit/src/TestFailure.cpp
Normal file
22
contrib/libpoco/CppUnit/src/TestFailure.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// TestFailure.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TestFailure.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestFailure.h"
|
||||
#include "CppUnit/Test.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Returns a short description of the failure.
|
||||
std::string TestFailure::toString()
|
||||
{
|
||||
return _failedTest->toString () + ": " + _thrownException->what();
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
29
contrib/libpoco/CppUnit/src/TestResult.cpp
Normal file
29
contrib/libpoco/CppUnit/src/TestResult.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
//
|
||||
// TestResult.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TestResult.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestResult.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Destroys a test result
|
||||
TestResult::~TestResult()
|
||||
{
|
||||
std::vector<TestFailure*>::iterator it;
|
||||
|
||||
for (it = _errors.begin(); it != _errors.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
for (it = _failures.begin(); it != _failures.end(); ++it)
|
||||
delete *it;
|
||||
|
||||
delete _syncObject;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
188
contrib/libpoco/CppUnit/src/TestRunner.cpp
Normal file
188
contrib/libpoco/CppUnit/src/TestRunner.cpp
Normal file
@ -0,0 +1,188 @@
|
||||
//
|
||||
// TestRunner.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TestRunner.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
#include "CppUnit/Test.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "CppUnit/TextTestResult.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
TestRunner::TestRunner():
|
||||
_ostr(std::cout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TestRunner::TestRunner(std::ostream& ostr):
|
||||
_ostr(ostr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
TestRunner::~TestRunner()
|
||||
{
|
||||
for (Mappings::iterator it = _mappings.begin(); it != _mappings.end(); ++it)
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
|
||||
void TestRunner::printBanner()
|
||||
{
|
||||
_ostr
|
||||
<< "Usage: driver [-all] [-print] [-wait] [name] ..." << std::endl
|
||||
<< " where name is the name of a test case class" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
bool TestRunner::run(const std::vector<std::string>& args)
|
||||
{
|
||||
std::string testCase;
|
||||
int numberOfTests = 0;
|
||||
bool success = true;
|
||||
bool all = false;
|
||||
bool wait = false;
|
||||
bool printed = false;
|
||||
|
||||
for (int i = 1; i < args.size(); i++)
|
||||
{
|
||||
const std::string& arg = args[i];
|
||||
if (arg == "-wait")
|
||||
{
|
||||
wait = true;
|
||||
continue;
|
||||
}
|
||||
else if (arg == "-all")
|
||||
{
|
||||
all = true;
|
||||
continue;
|
||||
}
|
||||
else if (arg == "-print")
|
||||
{
|
||||
for (Mappings::iterator it = _mappings.begin(); it != _mappings.end(); ++it)
|
||||
{
|
||||
print(it->first, it->second, 0);
|
||||
}
|
||||
printed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!all)
|
||||
{
|
||||
testCase = arg;
|
||||
|
||||
if (testCase == "")
|
||||
{
|
||||
printBanner();
|
||||
return false;
|
||||
}
|
||||
|
||||
Test* testToRun = 0;
|
||||
for (Mappings::iterator it = _mappings.begin(); !testToRun && it != _mappings.end(); ++it)
|
||||
{
|
||||
testToRun = find(testCase, it->second, it->first);
|
||||
}
|
||||
if (testToRun)
|
||||
{
|
||||
if (!run(testToRun)) success = false;
|
||||
}
|
||||
numberOfTests++;
|
||||
|
||||
if (!testToRun)
|
||||
{
|
||||
_ostr << "Test " << testCase << " not found." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (all)
|
||||
{
|
||||
for (Mappings::iterator it = _mappings.begin(); it != _mappings.end(); ++it)
|
||||
{
|
||||
if (!run(it->second)) success = false;
|
||||
numberOfTests++;
|
||||
}
|
||||
}
|
||||
|
||||
if (numberOfTests == 0 && !printed)
|
||||
{
|
||||
printBanner();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (wait)
|
||||
{
|
||||
_ostr << "<RETURN> to continue" << std::endl;
|
||||
std::cin.get();
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
bool TestRunner::run(Test* test)
|
||||
{
|
||||
TextTestResult result(_ostr);
|
||||
|
||||
test->run(&result);
|
||||
_ostr << result << std::endl;
|
||||
|
||||
return result.wasSuccessful();
|
||||
}
|
||||
|
||||
|
||||
void TestRunner::addTest(const std::string& name, Test* test)
|
||||
{
|
||||
_mappings.push_back(Mapping(name, test));
|
||||
}
|
||||
|
||||
|
||||
void TestRunner::print(const std::string& name, Test* pTest, int indent)
|
||||
{
|
||||
for (int i = 0; i < indent; ++i)
|
||||
_ostr << " ";
|
||||
_ostr << name << std::endl;
|
||||
TestSuite* pSuite = dynamic_cast<TestSuite*>(pTest);
|
||||
if (pSuite)
|
||||
{
|
||||
const std::vector<Test*>& tests = pSuite->tests();
|
||||
for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it)
|
||||
{
|
||||
print((*it)->toString(), *it, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Test* TestRunner::find(const std::string& name, Test* pTest, const std::string& testName)
|
||||
{
|
||||
if (testName.find(name) != std::string::npos)
|
||||
{
|
||||
return pTest;
|
||||
}
|
||||
else
|
||||
{
|
||||
TestSuite* pSuite = dynamic_cast<TestSuite*>(pTest);
|
||||
if (pSuite)
|
||||
{
|
||||
const std::vector<Test*>& tests = pSuite->tests();
|
||||
for (std::vector<Test*>::const_iterator it = tests.begin(); it != tests.end(); ++it)
|
||||
{
|
||||
Test* result = find(name, *it, (*it)->toString());
|
||||
if (result) return result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
49
contrib/libpoco/CppUnit/src/TestSuite.cpp
Normal file
49
contrib/libpoco/CppUnit/src/TestSuite.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// TestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TestSuite.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "CppUnit/TestResult.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Deletes all tests in the suite.
|
||||
void TestSuite::deleteContents()
|
||||
{
|
||||
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
|
||||
// Runs the tests and collects their result in a TestResult.
|
||||
void TestSuite::run(TestResult *result)
|
||||
{
|
||||
for (std::vector<Test*>::iterator it = _tests.begin(); it != _tests.end(); ++it)
|
||||
{
|
||||
if (result->shouldStop ())
|
||||
break;
|
||||
|
||||
Test *test = *it;
|
||||
test->run(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Counts the number of test cases that will be run by this test.
|
||||
int TestSuite::countTestCases()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (std::vector<Test*>::iterator it = _tests.begin (); it != _tests.end (); ++it)
|
||||
count += (*it)->countTestCases();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
225
contrib/libpoco/CppUnit/src/TextTestResult.cpp
Normal file
225
contrib/libpoco/CppUnit/src/TextTestResult.cpp
Normal file
@ -0,0 +1,225 @@
|
||||
//
|
||||
// TextTestResult.cpp
|
||||
//
|
||||
// $Id: //poco/1.4/CppUnit/src/TextTestResult.cpp#1 $
|
||||
//
|
||||
|
||||
|
||||
#include "CppUnit/TextTestResult.h"
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
#include "CppUnit/Test.h"
|
||||
#include "CppUnit/estring.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
TextTestResult::TextTestResult():
|
||||
_ostr(std::cout)
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
|
||||
TextTestResult::TextTestResult(std::ostream& ostr):
|
||||
_ostr(ostr)
|
||||
{
|
||||
setup();
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::setup()
|
||||
{
|
||||
#if !defined(_WIN32_WCE)
|
||||
const char* env = std::getenv("CPPUNIT_IGNORE");
|
||||
if (env)
|
||||
{
|
||||
std::string ignored = env;
|
||||
std::string::const_iterator it = ignored.begin();
|
||||
std::string::const_iterator end = ignored.end();
|
||||
while (it != end)
|
||||
{
|
||||
while (it != end && std::isspace(*it)) ++it;
|
||||
std::string test;
|
||||
while (it != end && !std::isspace(*it)) test += *it++;
|
||||
if (!test.empty()) _ignored.insert(test);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::addError(Test* test, CppUnitException* e)
|
||||
{
|
||||
if (_ignored.find(test->toString()) == _ignored.end())
|
||||
{
|
||||
TestResult::addError(test, e);
|
||||
_ostr << "ERROR" << std::flush;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ostr << "ERROR (ignored)" << std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::addFailure(Test* test, CppUnitException* e)
|
||||
{
|
||||
if (_ignored.find(test->toString()) == _ignored.end())
|
||||
{
|
||||
TestResult::addFailure(test, e);
|
||||
_ostr << "FAILURE" << std::flush;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ostr << "FAILURE (ignored)" << std::flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::startTest(Test* test)
|
||||
{
|
||||
TestResult::startTest(test);
|
||||
_ostr << "\n" << shortName(test->toString()) << ": ";
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::printErrors(std::ostream& stream)
|
||||
{
|
||||
if (testErrors() != 0)
|
||||
{
|
||||
stream << "\n";
|
||||
|
||||
if (testErrors() == 1)
|
||||
stream << "There was " << testErrors() << " error: " << std::endl;
|
||||
else
|
||||
stream << "There were " << testErrors() << " errors: " << std::endl;
|
||||
|
||||
int i = 1;
|
||||
for (std::vector<TestFailure*>::iterator it = errors().begin(); it != errors().end(); ++it)
|
||||
{
|
||||
TestFailure* failure = *it;
|
||||
CppUnitException* e = failure->thrownException();
|
||||
|
||||
stream << std::setw(2) << i
|
||||
<< ": "
|
||||
<< failure->failedTest()->toString() << "\n"
|
||||
<< " \"" << (e ? e->what() : "") << "\"\n"
|
||||
<< " in \""
|
||||
<< (e ? e->fileName() : std::string())
|
||||
<< "\", line ";
|
||||
if (e == 0)
|
||||
{
|
||||
stream << "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << e->lineNumber();
|
||||
if (e->data2LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
stream << " data lines " << e->data1LineNumber()
|
||||
<< ", " << e->data2LineNumber();
|
||||
}
|
||||
else if (e->data1LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
stream << " data line " << e->data1LineNumber();
|
||||
}
|
||||
}
|
||||
stream << "\n";
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::printFailures(std::ostream& stream)
|
||||
{
|
||||
if (testFailures() != 0)
|
||||
{
|
||||
stream << "\n";
|
||||
if (testFailures() == 1)
|
||||
stream << "There was " << testFailures() << " failure: " << std::endl;
|
||||
else
|
||||
stream << "There were " << testFailures() << " failures: " << std::endl;
|
||||
|
||||
int i = 1;
|
||||
|
||||
for (std::vector<TestFailure*>::iterator it = failures().begin(); it != failures().end(); ++it)
|
||||
{
|
||||
TestFailure* failure = *it;
|
||||
CppUnitException* e = failure->thrownException();
|
||||
|
||||
stream << std::setw(2) << i
|
||||
<< ": "
|
||||
<< failure->failedTest()->toString() << "\n"
|
||||
<< " \"" << (e ? e->what() : "") << "\"\n"
|
||||
<< " in \""
|
||||
<< (e ? e->fileName() : std::string())
|
||||
<< "\", line ";
|
||||
if (e == 0)
|
||||
{
|
||||
stream << "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << e->lineNumber();
|
||||
if (e->data2LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
stream << " data lines "
|
||||
<< e->data1LineNumber()
|
||||
<< ", " << e->data2LineNumber();
|
||||
}
|
||||
else if (e->data1LineNumber() != CppUnitException::CPPUNIT_UNKNOWNLINENUMBER)
|
||||
{
|
||||
stream << " data line " << e->data1LineNumber();
|
||||
}
|
||||
}
|
||||
stream << "\n";
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::print(std::ostream& stream)
|
||||
{
|
||||
printHeader(stream);
|
||||
printErrors(stream);
|
||||
printFailures(stream);
|
||||
}
|
||||
|
||||
|
||||
void TextTestResult::printHeader(std::ostream& stream)
|
||||
{
|
||||
stream << "\n\n";
|
||||
if (wasSuccessful())
|
||||
stream << "OK ("
|
||||
<< runTests() << " tests)"
|
||||
<< std::endl;
|
||||
else
|
||||
stream << "!!!FAILURES!!!" << std::endl
|
||||
<< "Runs: "
|
||||
<< runTests ()
|
||||
<< " Failures: "
|
||||
<< testFailures ()
|
||||
<< " Errors: "
|
||||
<< testErrors ()
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
std::string TextTestResult::shortName(const std::string& testName)
|
||||
{
|
||||
std::string::size_type pos = testName.rfind('.');
|
||||
if (pos != std::string::npos)
|
||||
return std::string(testName, pos + 1);
|
||||
else
|
||||
return testName;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
3
contrib/libpoco/Crypto/cmake/PocoCryptoConfig.cmake
Normal file
3
contrib/libpoco/Crypto/cmake/PocoCryptoConfig.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(PocoFoundation)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/PocoCryptoTargets.cmake")
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user