From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../tests/kconfigcompiler_test.cpp | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp (limited to 'kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp') diff --git a/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp new file mode 100644 index 000000000..31f3f5ee9 --- /dev/null +++ b/kdecore/kconfig_compiler/tests/kconfigcompiler_test.cpp @@ -0,0 +1,96 @@ +/* + Tests for KConfig Compiler + + Copyright (c) 2005 by Duncan Mac-Vicar + + ************************************************************************* + * * + * 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 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ + +#include +#include +#include +#include +#include "kconfigcompiler_test.h" + +using namespace KUnitTest; + +KUNITTEST_MODULE( kunittest_kconfigcompiler_test, "KConfigXT") +KUNITTEST_MODULE_REGISTER_TESTER( KConfigCompiler_Test ) + +typedef const char * CompilerTestSet[]; + +static CompilerTestSet testCases = +{ + "test1.cpp", "test1.h", + "test2.cpp", "test2.h", + "test3.cpp", "test3.h", + "test4.cpp", "test4.h", + "test5.cpp", "test5.h", + "test6.cpp", "test6.h", + "test7.cpp", "test7.h", + "test8a.cpp", "test8a.h", + "test8b.cpp", "test8b.h", + "test9.h", "test9.cpp", + "test_dpointer.cpp", "test_dpointer.h", + NULL +}; + +static CompilerTestSet willFailCases = +{ + // where is that QDir comming from? + //"test9.cpp", NULL + NULL +}; + + +void KConfigCompiler_Test::allTests() +{ + testExpectedOutput(); +} + +void KConfigCompiler_Test::testExpectedOutput() +{ + uint i = 0; + // Known to pass test cases + while (testCases[ i ]) + { + performCompare(QString::fromLatin1(testCases[ i ])); + ++i; + } + + // broken test cases + i= 0; + while (willFailCases[ i ]) + { + performCompare(QString::fromLatin1(willFailCases[ i ]), true); + ++i; + } +} + +void KConfigCompiler_Test::performCompare(const QString &fileName, bool fail) +{ + QFile file(fileName); + QFile fileRef(QString::fromLatin1(SRCDIR) + QString::fromLatin1("/") + fileName + QString::fromLatin1(".ref")); + + if ( file.open(IO_ReadOnly) && fileRef.open(IO_ReadOnly) ) + { + QString content = file.readAll(); + QString contentRef = fileRef.readAll(); + + if (!fail) + CHECK( content, contentRef); + else + XFAIL( content, contentRef); + } + else + { + SKIP("Can't open file for comparision"); + } +} -- cgit v1.2.3