1) vector<BaseClass> = bad juju, must use vector<BaseClass*>
2) BaseClass must have virtual dtor
3) make Run() pure virtual
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/test.h
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/test.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/test.h 2005-01-03
23:12:56 UTC (rev 12768)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/test.h 2005-01-03
23:21:25 UTC (rev 12769)
@@ -8,7 +8,8 @@
public:
bool Failed;
BaseTest();
- /*virtual void Run();*/
+ virtual ~BaseTest();
+ virtual void Run() = 0;
protected:
void Assert(char *message);
void IsTrue(bool condition);
@@ -24,6 +25,7 @@
class ModuleTest : public BaseTest
{
+public:
void Run();
};
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp
2005-01-03 23:12:56 UTC (rev 12768)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/tests/alltests.cpp
2005-01-03 23:21:25 UTC (rev 12769)
@@ -5,11 +5,11 @@
{
Failed = true;
}
-/*
-void BaseTest::Run()
+
+BaseTest::~BaseTest()
{
}
-*/
+
void BaseTest::Assert(char *message)
{
printf(message);
@@ -81,6 +81,17 @@
Failed = true;
}
+class BaseTestList : public vector<BaseTest*>
+{
+public:
+ ~BaseTestList()
+ {
+ for ( size_t i = 0; i < size(); i++ )
+ {
+ delete (*this)[i];
+ }
+ }
+};
class TestDispatcher
{
@@ -88,10 +99,10 @@
void Run()
{
int numberOfFailedTests = 0;
- vector<BaseTest> tests = GetTests();
+ BaseTestList tests = GetTests();
for (size_t i = 0; i < tests.size(); i++)
{
- BaseTest& test = tests[i];
+ BaseTest& test = *tests[i];
/*test.Run();*/
if (test.Failed)
numberOfFailedTests++;
@@ -105,10 +116,10 @@
}
private:
- vector<BaseTest> GetTests()
+ BaseTestList GetTests()
{
- vector<BaseTest> tests;
- tests.push_back(ModuleTest());
+ BaseTestList tests;
+ tests.push_back(new ModuleTest());
return tests;
}
};
Show replies by date