6#include <tqstringlist.h>
8#include <tdeaboutdata.h>
9#include <tdeapplication.h>
10#include <tdecmdlineargs.h>
15static bool check(TQString a, TQString b)
22 kdDebug() << "checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
25 kdDebug() << "checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
33void check_hyphenation( const TQStringList& tests, const TQStringList& results, const char* lang )
35 TQStringList::ConstIterator it, itres;
36 for ( it = tests.begin(), itres = results.begin(); it != tests.end() ; ++it, ++itres ) {
37 TQString result = hypher->hyphenate((*it), lang);
38 kdDebug() << (*it) << " hyphenates like this: " << result << endl;
39 check( result.replace(TQChar(0xad), '-'), *itres );
43int main ( int argc, char ** argv)
45 TDEAboutData aboutData( "KoHyphenator test", "KoHyphenator test", "0");
46 TDECmdLineArgs::init( argc, argv, &aboutData );
47 TDEApplication app( false, false, false);
52 catch (KoHyphenatorException &e)
54 kdDebug() << e.message() << endl;
58 TQStringList::ConstIterator it, itres;
61 TQStringList cs_tests = TQStringList() << "Žluťoučký" << "kůň" << "úpěl" <<
64 for ( it = cs_tests.begin(); it != cs_tests.end() ; ++it )
65 kdDebug() << (*it) << " hyphenates like this: " << hypher->hyphenate((*it), "cs") << endl;
68 TQStringList en_tests = TQStringList() << "Follow" << "white" << "rabbit";
69 TQStringList en_results = TQStringList() << "Fol-low" << "white" << "rab-bit";
70 check_hyphenation( en_tests, en_results, "en" );
72 TQStringList fr_tests = TQStringList() << "constitution" ;
73 TQStringList fr_results = TQStringList() << "consti-tu-tion" ;
74 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...
|