2010-06-01 18:06:31 +00:00
|
|
|
#ifndef TESTSUITE_H
|
|
|
|
#define TESTSUITE_H
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2010-06-02 04:45:44 +00:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "common/array.h"
|
2010-06-01 18:06:31 +00:00
|
|
|
|
|
|
|
namespace Testbed {
|
|
|
|
|
|
|
|
typedef bool (*invokingFunction)();
|
|
|
|
|
|
|
|
/**
|
2010-06-02 04:45:44 +00:00
|
|
|
* Make g_system available to test invoker functions
|
2010-06-01 18:06:31 +00:00
|
|
|
*/
|
2010-06-02 04:45:44 +00:00
|
|
|
extern OSystem *g_system;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This represents a feature to be tested
|
|
|
|
*/
|
|
|
|
|
2010-06-01 18:06:31 +00:00
|
|
|
struct Test {
|
2010-06-02 04:45:44 +00:00
|
|
|
Test(Common::String name, invokingFunction f) : featureName(name),
|
|
|
|
driver(f),
|
|
|
|
enabled(true),
|
|
|
|
passed(false) {}
|
|
|
|
|
|
|
|
Common::String featureName; ///< Name of feature to be tested
|
|
|
|
invokingFunction driver; ///< Pointer to the function that will invoke this feature test
|
|
|
|
bool enabled; ///< Decides whether or not this test is to be executed
|
|
|
|
bool passed; ///< Collects and stores result of this feature test
|
2010-06-01 18:06:31 +00:00
|
|
|
};
|
|
|
|
|
2010-06-02 04:45:44 +00:00
|
|
|
|
2010-06-01 18:06:31 +00:00
|
|
|
/**
|
|
|
|
* The basic Testsuite class
|
|
|
|
* All the other testsuites would inherit it and override its virtual methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Testsuite {
|
|
|
|
public:
|
|
|
|
Testsuite() {
|
|
|
|
extern OSystem *g_system;
|
|
|
|
_backend = g_system;
|
2010-06-02 04:45:44 +00:00
|
|
|
_numTestsPassed = 0;
|
|
|
|
_numTestsExecuted = 0;
|
2010-06-01 18:06:31 +00:00
|
|
|
}
|
|
|
|
~Testsuite() {}
|
2010-06-02 04:45:44 +00:00
|
|
|
inline int getNumTests() { return _testsToExecute.size(); }
|
|
|
|
inline int getNumTestsPassed() { return _numTestsPassed; }
|
|
|
|
inline int getNumTestsFailed() { return _numTestsExecuted - _numTestsPassed; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a test to the list of tests to be executed
|
|
|
|
*
|
|
|
|
* @param name the string description of the test, for display purposes
|
|
|
|
* @param f pointer to the function that invokes this test
|
|
|
|
*/
|
2010-06-01 18:06:31 +00:00
|
|
|
inline void addTest(Common::String name, invokingFunction f) {
|
|
|
|
Test featureTest(name, f);
|
|
|
|
_testsToExecute.push_back(featureTest);
|
|
|
|
}
|
2010-06-02 04:45:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The driver function for the testsuite
|
|
|
|
* All code should go in here.
|
|
|
|
*/
|
2010-06-01 18:06:31 +00:00
|
|
|
virtual int execute() = 0;
|
|
|
|
virtual const char *getName() = 0;
|
|
|
|
|
|
|
|
private:
|
2010-06-02 04:45:44 +00:00
|
|
|
OSystem *_backend; ///< Pointer to OSystem backend
|
|
|
|
int _numTestsPassed; ///< Number of tests passed
|
|
|
|
int _numTestsExecuted; ///< Number of tests executed
|
|
|
|
Common::Array<Test> _testsToExecute; ///< List of tests to be executed
|
2010-06-01 18:06:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace testbed
|
|
|
|
|
|
|
|
#endif
|