diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-02-24 15:57:41 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-02-24 15:57:41 -0500 |
| commit | b6d07f0ca14256a42268e69190891c56bf978bd4 (patch) | |
| tree | a2d5292207a0170e10724f83243423ebabe840a3 /sigmod/test/TestGame.cpp | |
| parent | dde935e48d44ca1b2b8ce993ae5bc187a8ca30fd (diff) | |
| download | sigen-b6d07f0ca14256a42268e69190891c56bf978bd4.tar.gz sigen-b6d07f0ca14256a42268e69190891c56bf978bd4.tar.xz sigen-b6d07f0ca14256a42268e69190891c56bf978bd4.zip | |
Moved the test for Sigmod to Game
Diffstat (limited to 'sigmod/test/TestGame.cpp')
| -rw-r--r-- | sigmod/test/TestGame.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
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 <MathStuf@gmail.com> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "TestSigmod.h" + +// Sigmod includes +#include "../Game.h" + +// Qt includes +#include <QtCore/QFile> +#include <QtTest/QTest> + +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) |
