diff options
| author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
|---|---|---|
| committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
| commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
| tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /lib/kotext/kohyphen/kohyphentest.cpp | |
| download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip | |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lib/kotext/kohyphen/kohyphentest.cpp')
| -rw-r--r-- | lib/kotext/kohyphen/kohyphentest.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/kotext/kohyphen/kohyphentest.cpp b/lib/kotext/kohyphen/kohyphentest.cpp new file mode 100644 index 000000000..d19526ce1 --- /dev/null +++ b/lib/kotext/kohyphen/kohyphentest.cpp @@ -0,0 +1,73 @@ +//KoHyphenator test, Lukas Tinkl <lukas.tinkl@suse.cz> + +#include <stdio.h> +#include <stdlib.h> + +#include <qstringlist.h> + +#include <kapplication.h> + +#include "kohyphen.h" +#include <kdebug.h> + +static bool check(QString a, QString b) +{ + if (a.isEmpty()) + a = QString::null; + if (b.isEmpty()) + b = QString::null; + if (a == b) { + kdDebug() << "checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl; + } + else { + kdDebug() << "checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl; + exit(1); + } + return true; +} + +KoHyphenator * hypher = 0L; + +void check_hyphenation( const QStringList& tests, const QStringList& results, const char* lang ) +{ + QStringList::ConstIterator it, itres; + for ( it = tests.begin(), itres = results.begin(); it != tests.end() ; ++it, ++itres ) { + QString result = hypher->hyphenate((*it), lang); + kdDebug() << (*it) << " hyphenates like this: " << result << endl; + check( result.replace(QChar(0xad),'-'), *itres ); + } +} + +int main (int argc, char ** argv) +{ + KApplication app(argc, argv, "KoHyphenator test"); + + try { + hypher = KoHyphenator::self(); + } + catch (KoHyphenatorException &e) + { + kdDebug() << e.message() << endl; + return 1; + } + + QStringList::ConstIterator it, itres; + + //testing Czech language, this text is in UTF-8! + QStringList cs_tests = QStringList() << "Žluťoučký" << "kůň" << "úpěl" << + "ďábelské" << "ódy"; + + for ( it = cs_tests.begin(); it != cs_tests.end() ; ++it ) + kdDebug() << (*it) << " hyphenates like this: " << hypher->hyphenate((*it), "cs") << endl; + + //testing English + QStringList en_tests = QStringList() << "Follow" << "white" << "rabbit"; + QStringList en_results = QStringList() << "Fol-low" << "white" << "rab-bit"; + check_hyphenation( en_tests, en_results, "en" ); + + QStringList fr_tests = QStringList() << "constitution" ; + QStringList fr_results = QStringList() << "consti-tu-tion" ; + check_hyphenation( fr_tests, fr_results, "fr" ); + + return 0; +} |
