1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
//KoHyphenator test, Lukas Tinkl <[email protected]>
#include <stdio.h>
#include <stdlib.h>
#include <tqstringlist.h>
#include <kapplication.h>
#include "kohyphen.h"
#include <kdebug.h>
static bool check(TQString a, TQString b)
{
if (a.isEmpty())
a = TQString();
if (b.isEmpty())
b = TQString();
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 TQStringList& tests, const TQStringList& results, const char* lang )
{
TQStringList::ConstIterator it, itres;
for ( it = tests.begin(), itres = results.begin(); it != tests.end() ; ++it, ++itres ) {
TQString result = hypher->hyphenate((*it), lang);
kdDebug() << (*it) << " hyphenates like this: " << result << endl;
check( result.replace(TQChar(0xad),'-'), *itres );
}
}
int main (int argc, char ** argv)
{
TDEApplication app(argc, argv, "KoHyphenator test");
try {
hypher = KoHyphenator::self();
}
catch (KoHyphenatorException &e)
{
kdDebug() << e.message() << endl;
return 1;
}
TQStringList::ConstIterator it, itres;
//testing Czech language, this text is in UTF-8!
TQStringList cs_tests = TQStringList() << "Ž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
TQStringList en_tests = TQStringList() << "Follow" << "white" << "rabbit";
TQStringList en_results = TQStringList() << "Fol-low" << "white" << "rab-bit";
check_hyphenation( en_tests, en_results, "en" );
TQStringList fr_tests = TQStringList() << "constitution" ;
TQStringList fr_results = TQStringList() << "consti-tu-tion" ;
check_hyphenation( fr_tests, fr_results, "fr" );
return 0;
}
|