From b6d07f0ca14256a42268e69190891c56bf978bd4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 24 Feb 2009 15:57:41 -0500 Subject: Moved the test for Sigmod to Game --- sigmod/test/CMakeLists.txt | 2 +- sigmod/test/TestGame.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++++ sigmod/test/TestGame.h | 52 ++++++++++++++++++++ sigmod/test/TestSigmod.cpp | 120 --------------------------------------------- sigmod/test/TestSigmod.h | 52 -------------------- 5 files changed, 173 insertions(+), 173 deletions(-) create mode 100644 sigmod/test/TestGame.cpp create mode 100644 sigmod/test/TestGame.h delete mode 100644 sigmod/test/TestSigmod.cpp delete mode 100644 sigmod/test/TestSigmod.h diff --git a/sigmod/test/CMakeLists.txt b/sigmod/test/CMakeLists.txt index 0f95198c..0d3322a0 100644 --- a/sigmod/test/CMakeLists.txt +++ b/sigmod/test/CMakeLists.txt @@ -32,6 +32,7 @@ make_test(sigmod-tests sigmod-vtests libraries Badge) make_test(sigmod-tests sigmod-vtests libraries CoinList) make_test(sigmod-tests sigmod-vtests libraries CoinListItem) make_test(sigmod-tests sigmod-vtests libraries EggGroup) +# make_test(sigmod-tests sigmod-vtests libraries Game) make_test(sigmod-tests sigmod-vtests libraries GlobalScript) make_test(sigmod-tests sigmod-vtests libraries Item) make_test(sigmod-tests sigmod-vtests libraries ItemType) @@ -46,7 +47,6 @@ make_test(sigmod-tests sigmod-vtests libraries MapWildListEncounter) make_test(sigmod-tests sigmod-vtests libraries Move) make_test(sigmod-tests sigmod-vtests libraries Nature) make_test(sigmod-tests sigmod-vtests libraries Rules) -# make_test(sigmod-tests sigmod-vtests libraries Sigmod) make_test(sigmod-tests sigmod-vtests libraries Skin) make_test(sigmod-tests sigmod-vtests libraries Sound) make_test(sigmod-tests sigmod-vtests libraries Species) diff --git a/sigmod/test/TestGame.cpp b/sigmod/test/TestGame.cpp new file mode 100644 index 00000000..86a3c676 --- /dev/null +++ b/sigmod/test/TestGame.cpp @@ -0,0 +1,120 @@ +/* + * Copyright 2008-2009 Ben Boeckel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +// Header include +#include "TestSigmod.h" + +// Sigmod includes +#include "../Game.h" + +// Qt includes +#include +#include + +using namespace Sigmod; + +void TestinitTestCase() +{ + TestSigmodObject::initTestCase(); + + m_game1 = m_game->newSigmod(); + m_game2 = m_game->newSigmod(); + m_game3 = m_game->newSigmod(); +} + +void TestcleanupTestCase() +{ + TestSigmodObject::cleanupTestCase(); +} + +void Testinit() +{ + TestSigmodObject::init(); + + makeConnections(m_game1); + makeConnections(m_game2); + makeConnections(m_game3); +} + +void Testcleanup() +{ + closeConnections(m_game1); + closeConnections(m_game2); + closeConnections(m_game3); + + TestSigmodObject::cleanup(); +} + +void Testvalidation() +{ + m_game1->validate(); + + QCOMPARE(m_warnings.size(), ); + QCOMPARE(m_errors.size(), ); + + m_game1->set(); + m_game1->validate(); + + QCOMPARE(m_warnings.size(), ); + QCOMPARE(m_errors.size(), ); +} + +void Testsaving() +{ + QDomDocument xml = Object::xml(m_game1); + QFile file("sigmod.xml"); + + QVERIFY(file.open(QIODevice::WriteOnly)); + file.write(xml.toByteArray()); + file.close(); +} + +void Testloading() +{ + QDomDocument xml; + QFile file("sigmod.xml"); + + m_game1->set(); + + QVERIFY(file.open(QIODevice::ReadOnly)); + QVERIFY(xml.setContent(&file)); + m_game1->load(xml.firstChildElement("Sigmod")); + + QCOMPARE(m_game1->(), ); +} + +void Testset() +{ + m_game2->set(); + m_game2->set(); + + QCOMPARE(m_game2->(), ); + + QCOMPARE(m_changedCount, 1); + + QCOMPARE(m_warnings.size(), 0); + QCOMPARE(m_errors.size(), 0); +} + +void Testassignment() +{ + *m_game3 = *m_game2; + + QCOMPARE(m_game3->(), ); +} + +QTEST_APPLESS_MAIN(TestSigmod) diff --git a/sigmod/test/TestGame.h b/sigmod/test/TestGame.h new file mode 100644 index 00000000..aa8373c7 --- /dev/null +++ b/sigmod/test/TestGame.h @@ -0,0 +1,52 @@ +/* + * Copyright 2008-2009 Ben Boeckel + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef SIGMOD_TESTSIGMOD +#define SIGMOD_TESTSIGMOD + +// Test includes +#include "TestSigmodObject.h" + +// Forward declarations +namespace Sigmod +{ +class Sigmod; +} + +class TestSigmod : public TestSigmodObject +{ + Q_OBJECT + + private slots: + void initTestCase(); + void cleanupTestCase(); + + void init(); + void cleanup(); + + void validation(); + void saving(); + void loading(); + + void assignment(); + private: + Sigmod::Sigmod* m_sigmod1; + Sigmod::Sigmod* m_sigmod2; + Sigmod::Sigmod* m_sigmod3; +}; + +#endif diff --git a/sigmod/test/TestSigmod.cpp b/sigmod/test/TestSigmod.cpp deleted file mode 100644 index 86a3c676..00000000 --- a/sigmod/test/TestSigmod.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2008-2009 Ben Boeckel - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -// Header include -#include "TestSigmod.h" - -// Sigmod includes -#include "../Game.h" - -// Qt includes -#include -#include - -using namespace Sigmod; - -void TestinitTestCase() -{ - TestSigmodObject::initTestCase(); - - m_game1 = m_game->newSigmod(); - m_game2 = m_game->newSigmod(); - m_game3 = m_game->newSigmod(); -} - -void TestcleanupTestCase() -{ - TestSigmodObject::cleanupTestCase(); -} - -void Testinit() -{ - TestSigmodObject::init(); - - makeConnections(m_game1); - makeConnections(m_game2); - makeConnections(m_game3); -} - -void Testcleanup() -{ - closeConnections(m_game1); - closeConnections(m_game2); - closeConnections(m_game3); - - TestSigmodObject::cleanup(); -} - -void Testvalidation() -{ - m_game1->validate(); - - QCOMPARE(m_warnings.size(), ); - QCOMPARE(m_errors.size(), ); - - m_game1->set(); - m_game1->validate(); - - QCOMPARE(m_warnings.size(), ); - QCOMPARE(m_errors.size(), ); -} - -void Testsaving() -{ - QDomDocument xml = Object::xml(m_game1); - QFile file("sigmod.xml"); - - QVERIFY(file.open(QIODevice::WriteOnly)); - file.write(xml.toByteArray()); - file.close(); -} - -void Testloading() -{ - QDomDocument xml; - QFile file("sigmod.xml"); - - m_game1->set(); - - QVERIFY(file.open(QIODevice::ReadOnly)); - QVERIFY(xml.setContent(&file)); - m_game1->load(xml.firstChildElement("Sigmod")); - - QCOMPARE(m_game1->(), ); -} - -void Testset() -{ - m_game2->set(); - m_game2->set(); - - QCOMPARE(m_game2->(), ); - - QCOMPARE(m_changedCount, 1); - - QCOMPARE(m_warnings.size(), 0); - QCOMPARE(m_errors.size(), 0); -} - -void Testassignment() -{ - *m_game3 = *m_game2; - - QCOMPARE(m_game3->(), ); -} - -QTEST_APPLESS_MAIN(TestSigmod) diff --git a/sigmod/test/TestSigmod.h b/sigmod/test/TestSigmod.h deleted file mode 100644 index aa8373c7..00000000 --- a/sigmod/test/TestSigmod.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2008-2009 Ben Boeckel - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef SIGMOD_TESTSIGMOD -#define SIGMOD_TESTSIGMOD - -// Test includes -#include "TestSigmodObject.h" - -// Forward declarations -namespace Sigmod -{ -class Sigmod; -} - -class TestSigmod : public TestSigmodObject -{ - Q_OBJECT - - private slots: - void initTestCase(); - void cleanupTestCase(); - - void init(); - void cleanup(); - - void validation(); - void saving(); - void loading(); - - void assignment(); - private: - Sigmod::Sigmod* m_sigmod1; - Sigmod::Sigmod* m_sigmod2; - Sigmod::Sigmod* m_sigmod3; -}; - -#endif -- cgit