6#include <tqstringlist.h>
8#include <tdeapplication.h>
13static bool check(TQString a, TQString b)
20 kdDebug() <<
"checking '" << a <<
"' against expected value '" << b <<
"'... " <<
"ok" << endl;
23 kdDebug() <<
"checking '" << a <<
"' against expected value '" << b <<
"'... " <<
"KO !" << endl;
31void check_hyphenation(
const TQStringList& tests,
const TQStringList& results,
const char* lang )
33 TQStringList::ConstIterator it, itres;
34 for ( it = tests.begin(), itres = results.begin(); it != tests.end() ; ++it, ++itres ) {
35 TQString result = hypher->
hyphenate((*it), lang);
36 kdDebug() << (*it) <<
" hyphenates like this: " << result << endl;
37 check( result.replace(TQChar(0xad),
'-'), *itres );
41int main (
int argc,
char ** argv)
43 TDEApplication app(argc, argv,
"KoHyphenator test");
48 catch (KoHyphenatorException &e)
50 kdDebug() << e.message() << endl;
54 TQStringList::ConstIterator it, itres;
57 TQStringList cs_tests = TQStringList() <<
"Žluťoučký" <<
"kůň" <<
"úpěl" <<
60 for ( it = cs_tests.begin(); it != cs_tests.end() ; ++it )
61 kdDebug() << (*it) <<
" hyphenates like this: " << hypher->
hyphenate((*it),
"cs") << endl;
64 TQStringList en_tests = TQStringList() <<
"Follow" <<
"white" <<
"rabbit";
65 TQStringList en_results = TQStringList() <<
"Fol-low" <<
"white" <<
"rab-bit";
66 check_hyphenation( en_tests, en_results,
"en" );
68 TQStringList fr_tests = TQStringList() <<
"constitution" ;
69 TQStringList fr_results = TQStringList() <<
"consti-tu-tion" ;
70 check_hyphenation( fr_tests, fr_results,
"fr" );
The KoHyphenator class provides an interface to the libhnj hyphenation library.
static KoHyphenator * self()
Returns the single KoHyphenator instance (singleton pattern) Beware that this might throw an exceptio...
TQString hyphenate(const TQString &str, const TQString &lang) const
Hyphenates the string str and returns the string with hyphenation marks in it.