]> git.sesse.net Git - mlt/commitdiff
Add the start of a unit test suite using QtTest.
authorDan Dennedy <dan@dennedy.org>
Wed, 1 May 2013 04:45:31 +0000 (21:45 -0700)
committerDan Dennedy <dan@dennedy.org>
Wed, 1 May 2013 04:45:31 +0000 (21:45 -0700)
src/tests/common.pri [new file with mode: 0644]
src/tests/test_properties/test_properties.cpp [new file with mode: 0644]
src/tests/test_properties/test_properties.pro [new file with mode: 0644]
src/tests/test_repository/test_repository.cpp [new file with mode: 0644]
src/tests/test_repository/test_repository.pro [new file with mode: 0644]
src/tests/tests.pro [new file with mode: 0644]

diff --git a/src/tests/common.pri b/src/tests/common.pri
new file mode 100644 (file)
index 0000000..85e978d
--- /dev/null
@@ -0,0 +1,16 @@
+QT       += testlib
+QT       -= gui
+
+CONFIG   += console
+CONFIG   -= app_bundle
+CONFIG   += testcase
+TEMPLATE = app
+DEFINES  += SRCDIR=\\\"$$PWD/\\\"
+
+win32 {
+    INCLUDEPATH += include/mlt++ include/mlt
+    LIBS += -Llib -lmlt++ -lmlt
+} else {
+    CONFIG += link_pkgconfig
+    PKGCONFIG += mlt++
+}
diff --git a/src/tests/test_properties/test_properties.cpp b/src/tests/test_properties/test_properties.cpp
new file mode 100644 (file)
index 0000000..06dd8f2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with consumer library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <QString>
+#include <QtTest>
+
+#include <mlt++/Mlt.h>
+using namespace Mlt;
+
+class TestProperties: public QObject
+{
+    Q_OBJECT
+
+public:
+    TestProperties() {}
+
+private Q_SLOTS:
+    void InstantiationIsAReference()
+    {
+        Properties p;
+        QCOMPARE(p.ref_count(), 1);
+    }
+
+    void CopyAddsReference()
+    {
+        Properties p;
+        Properties q = p;
+        QCOMPARE(p.ref_count(), 2);
+    }
+
+    void DestructionRemovesReference()
+    {
+        Properties p;
+        Properties* q = new Properties(p);
+        QCOMPARE(p.ref_count(), 2);
+        delete q;
+        QCOMPARE(p.ref_count(), 1);
+    }
+};
+
+QTEST_APPLESS_MAIN(TestProperties)
+
+#include "test_properties.moc"
diff --git a/src/tests/test_properties/test_properties.pro b/src/tests/test_properties/test_properties.pro
new file mode 100644 (file)
index 0000000..0846b08
--- /dev/null
@@ -0,0 +1,4 @@
+include (../common.pri)
+TARGET   = test_properties
+SOURCES  = test_properties.cpp
+DEFINES  += SRCDIR=\\\"$$PWD/\\\"
diff --git a/src/tests/test_repository/test_repository.cpp b/src/tests/test_repository/test_repository.cpp
new file mode 100644 (file)
index 0000000..8cd8d4f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2013 Dan Dennedy <dan@dennedy.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with consumer library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <QString>
+#include <QtTest>
+
+#include <mlt++/Mlt.h>
+using namespace Mlt;
+
+class TestRepository : public QObject
+{
+    Q_OBJECT
+    
+public:
+    TestRepository() {}
+    
+private Q_SLOTS:
+    void ThereAreProducers()
+    {
+        Repository* r = Factory::init();
+        Properties* producers = r->producers();
+        QVERIFY(producers->is_valid());
+        if (producers->is_valid())
+            QVERIFY(producers->count() > 0);
+        delete producers;
+    }
+
+    void ThereAreConsumers()
+    {
+        Repository* r = Factory::init();
+        Properties* consumers = r->consumers();
+        QVERIFY(consumers->is_valid());
+        if (consumers->is_valid())
+            QVERIFY(consumers->count() > 0);
+        delete consumers;
+    }
+};
+
+QTEST_APPLESS_MAIN(TestRepository)
+
+#include "test_repository.moc"
diff --git a/src/tests/test_repository/test_repository.pro b/src/tests/test_repository/test_repository.pro
new file mode 100644 (file)
index 0000000..e9c3690
--- /dev/null
@@ -0,0 +1,4 @@
+include(../common.pri)
+TARGET = test_repository
+SOURCES += test_repository.cpp
+
diff --git a/src/tests/tests.pro b/src/tests/tests.pro
new file mode 100644 (file)
index 0000000..4a02276
--- /dev/null
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS = test_properties \
+    test_repository