summaryrefslogtreecommitdiffstats
path: root/sigmod
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-02-14 16:02:07 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-02-14 16:02:07 -0500
commit8efa4a77923c3c132ab347b56dd0b1298706c8d1 (patch)
tree09400e88162a56827da823a22473c2c442eedb15 /sigmod
parent48ee83782aa9712d24795298ed48f4ac4740441e (diff)
downloadsigen-8efa4a77923c3c132ab347b56dd0b1298706c8d1.tar.gz
sigen-8efa4a77923c3c132ab347b56dd0b1298706c8d1.tar.xz
sigen-8efa4a77923c3c132ab347b56dd0b1298706c8d1.zip
Boilerplate code for Sigmod testing
Diffstat (limited to 'sigmod')
-rw-r--r--sigmod/test/TestSigmod.cpp118
-rw-r--r--sigmod/test/TestSigmod.h52
2 files changed, 170 insertions, 0 deletions
diff --git a/sigmod/test/TestSigmod.cpp b/sigmod/test/TestSigmod.cpp
new file mode 100644
index 00000000..bfc3e149
--- /dev/null
+++ b/sigmod/test/TestSigmod.cpp
@@ -0,0 +1,118 @@
+/*
+ * 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 "../Sigmod.h"
+
+// Qt includes
+#include <QtCore/QFile>
+#include <QtTest/QTest>
+
+void TestSigmod::initTestCase()
+{
+ TestSigmodObject::initTestCase();
+
+ m_sigmod1 = m_sigmod->newSigmod();
+ m_sigmod2 = m_sigmod->newSigmod();
+ m_sigmod3 = m_sigmod->newSigmod();
+}
+
+void TestSigmod::cleanupTestCase()
+{
+ TestSigmodObject::cleanupTestCase();
+}
+
+void TestSigmod::init()
+{
+ TestSigmodObject::init();
+
+ makeConnections(m_sigmod1);
+ makeConnections(m_sigmod2);
+ makeConnections(m_sigmod3);
+}
+
+void TestSigmod::cleanup()
+{
+ closeConnections(m_sigmod1);
+ closeConnections(m_sigmod2);
+ closeConnections(m_sigmod3);
+
+ TestSigmodObject::cleanup();
+}
+
+void TestSigmod::validation()
+{
+ m_sigmod1->validate();
+
+ QCOMPARE(m_warnings.size(), );
+ QCOMPARE(m_errors.size(), );
+
+ m_sigmod1->set();
+ m_sigmod1->validate();
+
+ QCOMPARE(m_warnings.size(), );
+ QCOMPARE(m_errors.size(), );
+}
+
+void TestSigmod::saving()
+{
+ QDomDocument xml = Sigmod::Object::xml(m_sigmod1);
+ QFile file("sigmod.xml");
+
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write(xml.toByteArray());
+ file.close();
+}
+
+void TestSigmod::loading()
+{
+ QDomDocument xml;
+ QFile file("sigmod.xml");
+
+ m_sigmod1->set();
+
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QVERIFY(xml.setContent(&file));
+ m_sigmod1->load(xml.firstChildElement("Sigmod"));
+
+ QCOMPARE(m_sigmod1->(), );
+}
+
+void TestSigmod::set()
+{
+ m_sigmod2->set();
+ m_sigmod2->set();
+
+ QCOMPARE(m_sigmod2->(), );
+
+ QCOMPARE(m_changedCount, 1);
+
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 0);
+}
+
+void TestSigmod::assignment()
+{
+ *m_sigmod3 = *m_sigmod2;
+
+ QCOMPARE(m_sigmod3->(), );
+}
+
+QTEST_APPLESS_MAIN(TestSigmod)
diff --git a/sigmod/test/TestSigmod.h b/sigmod/test/TestSigmod.h
new file mode 100644
index 00000000..aa8373c7
--- /dev/null
+++ b/sigmod/test/TestSigmod.h
@@ -0,0 +1,52 @@
+/*
+ * 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/>.
+ */
+
+#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