[Telepathy-commits] [telepathy-qt4/master] Added automated test for key-file.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Mon Jan 5 08:18:50 PST 2009
---
tests/Makefile.am | 34 +++++++++++++++++++++++-
tests/key-file.cpp | 49 ++++++++++++++++++++++++++++++++++
tests/test-key-file-format-error.ini | 4 +++
tests/test-key-file.ini | 9 ++++++
4 files changed, 95 insertions(+), 1 deletions(-)
create mode 100644 tests/key-file.cpp
create mode 100644 tests/test-key-file-format-error.ini
create mode 100644 tests/test-key-file.ini
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 24745cc..6d47fac 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,7 +3,39 @@ SUBDIRS = \
pinocchio \
prototype
+TESTS = \
+ test-key-file
+
+noinst_PROGRAMS = $(TESTS)
+
+test_key_file_SOURCES = key-file.cpp
+
+BUILT_SOURCES = \
+ key-file.moc.hpp
+
+LDADD = \
+ $(QTCORE_LIBS) \
+ $(QTTEST_LIBS) \
+ ${top_builddir}/TelepathyQt4/libtelepathy-qt4.la
+
+LIB_CFLAGS = \
+ $(QTCORE_CFLAGS) \
+ $(QTTEST_CFLAGS) \
+ -I${top_srcdir}
+
+AM_CXXFLAGS = \
+ $(ERROR_CXXFLAGS) \
+ $(LIB_CFLAGS)
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
EXTRA_DIST = \
README \
dbus-1/services/spurious.service \
- telepathy/managers/spurious.manager
+ telepathy/managers/spurious.manager \
+ test-key-file.ini \
+ test-key-file-format-error.ini
+
+%.moc.hpp: %.cpp
+ $(MOC) $(LIB_CFLAGS) -i $< -o $@
diff --git a/tests/key-file.cpp b/tests/key-file.cpp
new file mode 100644
index 0000000..892570f
--- /dev/null
+++ b/tests/key-file.cpp
@@ -0,0 +1,49 @@
+#include <QtTest/QtTest>
+
+#include <TelepathyQt4/KeyFile>
+
+using namespace Telepathy;
+
+class TestKeyFile : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void testKeyFile();
+};
+
+void TestKeyFile::testKeyFile()
+{
+ KeyFile defaultKeyFile;
+ QCOMPARE(defaultKeyFile.status(), KeyFile::None);
+
+ KeyFile notFoundkeyFile("test-key-file-not-found.ini");
+ QCOMPARE(notFoundkeyFile.status(), KeyFile::NotFoundError);
+
+ KeyFile formatErrorkeyFile("test-key-file-format-error.ini");
+ QCOMPARE(formatErrorkeyFile.status(), KeyFile::FormatError);
+
+ KeyFile keyFile("test-key-file.ini");
+ QCOMPARE(keyFile.status(), KeyFile::NoError);
+
+ QCOMPARE(keyFile.allGroups(),
+ QStringList() << QString() <<
+ "test group 1" <<
+ "test group 2");
+
+ QStringList allKeys = keyFile.allKeys();
+ allKeys.sort();
+ QCOMPARE(allKeys,
+ QStringList() << "a" << "b" << "c" << "d" << "e");
+
+ keyFile.setGroup("test group 1");
+ QCOMPARE(keyFile.contains("f"), false);
+ QCOMPARE(keyFile.value("c").length(), 5);
+
+ keyFile.setGroup("test group 2");
+ QCOMPARE(keyFile.contains("e"), true);
+ QCOMPARE(keyFile.value("e"), QString("space"));
+}
+
+QTEST_MAIN(TestKeyFile)
+#include "key-file.moc.hpp"
diff --git a/tests/test-key-file-format-error.ini b/tests/test-key-file-format-error.ini
new file mode 100644
index 0000000..5197c57
--- /dev/null
+++ b/tests/test-key-file-format-error.ini
@@ -0,0 +1,4 @@
+a 1
+b=2
+
+[test group 1
diff --git a/tests/test-key-file.ini b/tests/test-key-file.ini
new file mode 100644
index 0000000..e38f70f
--- /dev/null
+++ b/tests/test-key-file.ini
@@ -0,0 +1,9 @@
+a=1
+b=2
+
+[test group 1]
+c=\s\t\n\r\\
+d=true
+
+[test group 2]
+e = space
--
1.5.6.5
More information about the Telepathy-commits
mailing list