Originally committed to SVN as r2442.

This commit is contained in:
Rodrigo Braz Monteiro 2008-11-10 01:23:45 +00:00
parent 33583d3aaa
commit 0788a45b3e
4 changed files with 61 additions and 29 deletions

View File

@ -33,10 +33,12 @@
// Contact: mailto:zeratul@cellosoft.com
//
#include "../suites.h"
#if ATHENASUB_TEST == 1
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "../../../aegilib/include/athenasub/athenasub.h"
#include "../suites.h"
#include "../../../athenasub/include/athenasub/athenasub.h"
using namespace Athenasub;
@ -44,51 +46,66 @@ class AthenasubTimeTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(AthenasubTimeTest);
CPPUNIT_TEST(testBounds);
CPPUNIT_TEST(testComparison);
CPPUNIT_TEST(testOperators);
CPPUNIT_TEST(testSetGet);
CPPUNIT_TEST_SUITE_END();
private:
Time a;
Time *b;
Time *c;
Time *d;
Time e;
public:
void setUp()
{
a;
b = new Time(0);
c = new Time(5000);
d = new Time(-500);
e.SetMS(-1000);
}
void tearDown()
{
delete b;
delete c;
}
void testComparison()
{
Time a;
Time b(0);
Time c(5000);
Time d(-500);
CPPUNIT_ASSERT(a == a);
CPPUNIT_ASSERT(a <= a);
CPPUNIT_ASSERT(a >= a);
CPPUNIT_ASSERT(a == *b);
CPPUNIT_ASSERT(a == *d);
CPPUNIT_ASSERT(a != *c);
CPPUNIT_ASSERT(*b != *c);
CPPUNIT_ASSERT(a < *c);
CPPUNIT_ASSERT(a <= *c);
CPPUNIT_ASSERT(*c > *b);
CPPUNIT_ASSERT(*c >= *b);
CPPUNIT_ASSERT(a == b);
CPPUNIT_ASSERT(a == d);
CPPUNIT_ASSERT(a != c);
CPPUNIT_ASSERT(b != c);
CPPUNIT_ASSERT(a < c);
CPPUNIT_ASSERT(a <= c);
CPPUNIT_ASSERT(c > b);
CPPUNIT_ASSERT(c >= b);
}
void testBounds()
{
CPPUNIT_ASSERT(d->GetMS() >= 0);
CPPUNIT_ASSERT(e.GetMS() >= 0);
Time a(-500);
CPPUNIT_ASSERT(a.GetMS() >= 0);
}
void testSetGet()
{
Time a;
CPPUNIT_ASSERT(a.GetMS() == 0);
a.SetMS(5000);
CPPUNIT_ASSERT(a.GetMS() == 5000);
a.SetMS(-5000);
CPPUNIT_ASSERT(a.GetMS() == 0);
}
void testOperators()
{
Time a(500);
CPPUNIT_ASSERT(a + 300 == Time(800));
CPPUNIT_ASSERT(a - 300 == Time(200));
CPPUNIT_ASSERT(a - 600 == Time(0));
}
};
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(AthenasubTimeTest,AegisubSuites::athenasub());
#endif

View File

@ -48,7 +48,9 @@ int main()
{
CppUnit::TextUi::TestRunner runner;
#if ATHENASUB_TEST == 1
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(AegisubSuites::athenasub()).makeTest());
#endif
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
bool result = runner.run("",false);

View File

@ -33,6 +33,19 @@
// Contact: mailto:zeratul@cellosoft.com
//
#include <string>
//////////////////////////////
// Enable/disable test suites
#define ATHENASUB_TEST 1
///////////////////////
// Name of test suites
namespace AegisubSuites {
static std::string athenasub() { return "athenasub"; }
#if ATHENASUB_TEST == 1
inline std::string athenasub() { return "athenasub"; }
#endif
};