summaryrefslogtreecommitdiffstats
path: root/kspell2/tests
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kspell2/tests
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
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
Diffstat (limited to 'kspell2/tests')
-rw-r--r--kspell2/tests/Makefile.am24
-rw-r--r--kspell2/tests/backgroundtest.cpp167
-rw-r--r--kspell2/tests/backgroundtest.h45
-rw-r--r--kspell2/tests/test.cpp100
-rw-r--r--kspell2/tests/test_config.cpp38
-rw-r--r--kspell2/tests/test_configdialog.cpp40
-rw-r--r--kspell2/tests/test_dialog.cpp65
-rw-r--r--kspell2/tests/test_dialog.h42
-rw-r--r--kspell2/tests/test_filter.cpp50
-rw-r--r--kspell2/tests/test_highlighter.cpp41
10 files changed, 612 insertions, 0 deletions
diff --git a/kspell2/tests/Makefile.am b/kspell2/tests/Makefile.am
new file mode 100644
index 000000000..88a0d03b6
--- /dev/null
+++ b/kspell2/tests/Makefile.am
@@ -0,0 +1,24 @@
+AM_CPPFLAGS = -DKDE_NO_COMPAT -DQT_NO_COMPAT -I$(top_srcdir)/kspell2 -I$(top_srcdir)/kspell2/ui $(all_includes)
+METASOURCES = AUTO
+
+
+check_PROGRAMS = test test_filter backgroundtest \
+ test_dialog test_highlighter test_configdialog
+
+test_SOURCES = test.cpp
+test_LDADD = ../ui/libkspell2.la $(LIB_KDECORE)
+
+test_filter_SOURCES = test_filter.cpp
+test_filter_LDADD = ../ui/libkspell2.la $(LIB_KDECORE)
+
+backgroundtest_SOURCES = backgroundtest.cpp
+backgroundtest_LDADD = ../ui/libkspell2.la $(LIB_KDECORE)
+
+test_dialog_SOURCES = test_dialog.cpp
+test_dialog_LDADD = ../ui/libkspell2.la $(LIB_KDECORE)
+
+test_highlighter_SOURCES = test_highlighter.cpp
+test_highlighter_LDADD = ../ui/libkspell2_noinst.la ../libkspell2base.la $(LIB_KDECORE)
+
+test_configdialog_SOURCES = test_configdialog.cpp
+test_configdialog_LDADD = ../ui/libkspell2_noinst.la ../libkspell2base.la $(LIB_KDECORE)
diff --git a/kspell2/tests/backgroundtest.cpp b/kspell2/tests/backgroundtest.cpp
new file mode 100644
index 000000000..a0fb7c69b
--- /dev/null
+++ b/kspell2/tests/backgroundtest.cpp
@@ -0,0 +1,167 @@
+/**
+ * backgroundtest.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "backgroundtest.h"
+#include "backgroundtest.moc"
+
+#include "broker.h"
+using namespace KSpell2;
+
+#include <kapplication.h>
+#include <kdebug.h>
+
+const char *text = "Rationale \
+========= \
+ \
+This code is intended to provide an implementation of the W3C's XPath \
+specification for KHTML. XPath isn't particularly useful on its own, however\
+it is an essential building block for the implementation of other standards \
+like XSLT and XQuery. XPath is supported to a greater or lesser extent by both\
+IE and Mozilla so it is likely to become increasingly important over the next\
+few years.\
+ \
+Why write another XPath implementation? \
+======================================= \
+ \
+The are already a number of XPath implementations available under free \
+licenses including Mozilla's, libxml2, Xerces and probably others, so it is \
+reasonable to ask why there should be another one. \
+ \
+It would certainly be possible to integrate one of these implementations into\
+KHTML, but it would actually be quite a lot of work. I looked at all of the\
+implementations mentioned with a view to using this approach before I decided\
+to start from scratch.\
+ \
+Mozilla XPath\
+-------------\
+ \
+Seems to be incomplete, and though the code was originally standalone it now\
+seems to be tied to the mozilla codebase quite tightly. This makes porting it\
+a lot of work, and makes working with the mozilla team on fixing bugs\
+etc. hard as the code bases would have diverged quite a lot.\
+ \
+Xerces XPath (C++ version)\
+--------------------------\
+ \
+The Xerces code seemed pretty clean and was reasonably understandable, however\
+it doesn't seem to be used very much which greatly reduces the utility. As\
+with the mozilla code, porting it to use KHTML's DOM would take a fair bit of \
+work. The main issue here being that Xerces is based around pointers to Nodes\
+rather than implicitly shared Node objects.\
+ \
+libxml2 \
+------- \
+ \
+This is the most obvious library to reuse as it is currently used to generate\
+the KDE documentation, and is also a very complete and fast\
+implementation. The down side of using this code is that it would either need\
+a new DOM implementation in KHTML (which used the libxml2 structures), a \
+wrapper library that made on of the DOM trees support the API of the other, or\
+binding layer that parsed the XML twice and somehow maintained a mapping\
+between the two DOM trees. Unfortunately the documentation of this library is\
+less than great, which would add to the problems.\
+ \
+The C++ wrappers to libxml2 are considerably closer to what I was looking\
+for. They are well documented and have a well structured API. Unfortunately\
+using this library still requires some mechanism to integrate the two\
+underlying DOM implementations.\
+ \
+KHTML XPath\
+----------- \
+ \
+There are some advantages to the XPath implementation Zack and I are working\
+on, namely: \
+ \
+- Ease of integration with the rest of kjs/khtml.\
+- Use of dom2 traversal (which will also be available to use directly).\
+- C++ rather than C and a wrapper (reducing the overheads).\
+- The code is clean and uses familiar types and idioms. \
+ \
+We intend the code to be build on top of the DOM api rather than tying it\
+directly to the Qt or KHTML XML implementations. This will allow us to take\
+advantage of any improvements that might be made to the underlying parser\
+etc. The DOM2 traversal APIs provide a set of classes that map almost directly \
+to the XPath location steps, since we need to implement these facilities\
+anyway writing the relatively small amount of code needed to support XPath\
+seems sensible.\
+ \
+Building \
+========\
+ \
+This code needs to live in a subdir off the khtml directory in kdelibs. The\
+subdir should be called 'xpath'. The easiest way to regenerate the makefiles\
+is to go to the root of the kdelibs tree and run: \
+ create_makefiles khtml/xpath\
+ \
+This code is intended to compile, but not to work.\
+ \
+Usage \
+===== \
+ \
+./test_xpath simple.xml\
+./test_values\
+./test_functions \
+ \
+Notes\
+===== \
+ \
+apidoc Duh! It's the docs \
+working Stuff that i'm mining for ideas\
+\
+Discussion\
+========== \
+ \
+If you want to talk about this code feel free to mail us.";
+
+BackgroundTest::BackgroundTest()
+ : QObject( 0 )
+{
+ m_checker = new BackgroundChecker( Broker::openBroker(), this );
+ connect( m_checker, SIGNAL(done()),
+ SLOT(slotDone()) );
+ connect( m_checker, SIGNAL(misspelling(const QString&, int)),
+ SLOT(slotMisspelling(const QString&, int)) );
+ m_len = strlen( text );
+ m_checker->checkText( text );
+ m_timer.start();
+}
+
+void BackgroundTest::slotDone()
+{
+ kdDebug()<<"Text of length "<<m_len<<" checked in "
+ << m_timer.elapsed() << " msec."<<endl;
+ QApplication::exit();
+}
+
+void BackgroundTest::slotMisspelling( const QString& word, int start )
+{
+ kdDebug()<<"Misspelling \""<< word << "\" at " << start << endl;
+ m_checker->continueChecking();
+}
+
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "KSpell2Test");
+
+ BackgroundTest test;
+
+ return app.exec();
+}
diff --git a/kspell2/tests/backgroundtest.h b/kspell2/tests/backgroundtest.h
new file mode 100644
index 000000000..6dac80af7
--- /dev/null
+++ b/kspell2/tests/backgroundtest.h
@@ -0,0 +1,45 @@
+/**
+ * backgroundtest.h
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef BACKGROUNDTEST_H
+#define BACKGROUNDTEST_H
+
+#include <qobject.h>
+#include <qdatetime.h>
+
+#include "backgroundchecker.h"
+
+class BackgroundTest : public QObject
+{
+ Q_OBJECT
+public:
+ BackgroundTest();
+
+protected slots:
+ void slotDone();
+ void slotMisspelling( const QString& word, int start );
+
+private:
+ KSpell2::BackgroundChecker *m_checker;
+ QTime m_timer;
+ int m_len;
+};
+
+#endif
diff --git a/kspell2/tests/test.cpp b/kspell2/tests/test.cpp
new file mode 100644
index 000000000..15425527d
--- /dev/null
+++ b/kspell2/tests/test.cpp
@@ -0,0 +1,100 @@
+/**
+ * test.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "broker.h"
+#include "dictionary.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+
+#include <qdatetime.h>
+
+using namespace KSpell2;
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "KSpell2Test");
+
+ Broker::Ptr broker = Broker::openBroker();
+
+ kdDebug()<< "Clients are " << broker->clients() << endl;
+ kdDebug()<< "Languages are " << broker->languages() << endl;
+
+ Dictionary *dict = broker->dictionary( "en_US" );
+
+ QStringList words;
+
+ words << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted"
+ << "hello" << "helo" << "enviroment" << "guvernment" << "farted";
+
+ QTime mtime;
+ mtime.start();
+ for ( QStringList::Iterator itr = words.begin(); itr != words.end(); ++itr ) {
+ if ( dict && !dict->check( *itr ) ) {
+ //kdDebug()<<"Word " << *itr <<" is misspelled"<<endl;
+ QStringList sug = dict->suggest( *itr );
+ //kdDebug()<<"Suggestions : "<<sug<<endl;
+ }
+ }
+ //mtime.stop();
+ kdDebug()<<"Elapsed time is "<<mtime.elapsed()<<endl;
+
+ delete dict;
+
+ return 0;
+}
diff --git a/kspell2/tests/test_config.cpp b/kspell2/tests/test_config.cpp
new file mode 100644
index 000000000..4ef3f588e
--- /dev/null
+++ b/kspell2/tests/test_config.cpp
@@ -0,0 +1,38 @@
+/**
+ * test_config.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "configdialog.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+using namespace KSpell2;
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "KSpell2Test");
+
+ SettingsDialog *dialog = new SettingsDialog( 0 );
+
+ dialog->show();
+
+ app.setMainWidget( dialog );
+
+ return app.exec();
+}
diff --git a/kspell2/tests/test_configdialog.cpp b/kspell2/tests/test_configdialog.cpp
new file mode 100644
index 000000000..e90d01d7c
--- /dev/null
+++ b/kspell2/tests/test_configdialog.cpp
@@ -0,0 +1,40 @@
+/**
+ * test_configdialog.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "configdialog.h"
+#include "broker.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+using namespace KSpell2;
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "KSpell2Test");
+
+ Broker::Ptr broker = Broker::openBroker();
+ ConfigDialog *dialog = new ConfigDialog( broker, 0 );
+
+ dialog->show();
+
+ app.setMainWidget( dialog );
+
+ return app.exec();
+}
diff --git a/kspell2/tests/test_dialog.cpp b/kspell2/tests/test_dialog.cpp
new file mode 100644
index 000000000..d481de00d
--- /dev/null
+++ b/kspell2/tests/test_dialog.cpp
@@ -0,0 +1,65 @@
+/**
+ * test_dialog.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "test_dialog.h"
+#include "test_dialog.moc"
+
+#include "backgroundchecker.h"
+#include "dictionary.h"
+#include "filter.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+using namespace KSpell2;
+
+TestDialog::TestDialog()
+ : QObject( 0, "testdialog" )
+{
+
+}
+
+void TestDialog::check( const QString& buffer )
+{
+ KSpell2::Dialog *dlg = new KSpell2::Dialog(
+ new BackgroundChecker( Broker::openBroker(), this, "checker" ),
+ 0, "my dialog" );
+ connect( dlg, SIGNAL(done(const QString&)),
+ SLOT(doneChecking(const QString&)) );
+ dlg->setBuffer( buffer );
+ dlg->show();
+}
+
+void TestDialog::doneChecking( const QString& buf )
+{
+ kdDebug()<<"Done with :"<<buf<<endl;
+ qApp->quit();
+}
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "KSpell2Test");
+
+ TestDialog test;
+ test.check( "This is a sample buffer. Whih this thingg will "
+ "be checkin for misstakes. Whih, Enviroment, govermant. Whih."
+ );
+
+ return app.exec();
+}
diff --git a/kspell2/tests/test_dialog.h b/kspell2/tests/test_dialog.h
new file mode 100644
index 000000000..2ce70aaeb
--- /dev/null
+++ b/kspell2/tests/test_dialog.h
@@ -0,0 +1,42 @@
+/**
+ * test_dialog.h
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef TEST_DIALOG_H
+#define TEST_DIALOG_H
+
+#include "dialog.h"
+#include "broker.h"
+
+#include <qobject.h>
+
+class TestDialog : public QObject
+{
+ Q_OBJECT
+public:
+ TestDialog();
+
+public slots:
+ void check( const QString& buffer );
+ void doneChecking( const QString& );
+private:
+ KSpell2::Broker *m_broker;
+};
+
+#endif
diff --git a/kspell2/tests/test_filter.cpp b/kspell2/tests/test_filter.cpp
new file mode 100644
index 000000000..d55b3801f
--- /dev/null
+++ b/kspell2/tests/test_filter.cpp
@@ -0,0 +1,50 @@
+/**
+ * test_filter.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "filter.h"
+
+
+#include <kapplication.h>
+#include <kdebug.h>
+
+using namespace KSpell2;
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "Filter");
+
+ QString buffer = QString( "This is a sample buffer. Please test me." );
+
+ Filter filter;
+ filter.setBuffer( buffer );
+
+ Word w;
+
+ while ( ! (w=filter.nextWord()).end ) {
+ kdDebug()<< "Found word \""<< w.word << "\" which starts at position "
+ << w.start <<endl;
+ }
+
+ filter.setBuffer( buffer );
+
+
+
+ return 0;
+}
diff --git a/kspell2/tests/test_highlighter.cpp b/kspell2/tests/test_highlighter.cpp
new file mode 100644
index 000000000..faeab0d27
--- /dev/null
+++ b/kspell2/tests/test_highlighter.cpp
@@ -0,0 +1,41 @@
+/**
+ * test_highlighter.cpp
+ *
+ * Copyright (C) 2004 Zack Rusin <zack@kde.org>
+ *
+ * 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.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "highlighter.h"
+#include "dictionary.h"
+#include "filter.h"
+
+#include <kapplication.h>
+#include <kdebug.h>
+
+#include <qtextedit.h>
+
+int main( int argc, char** argv )
+{
+ KApplication app(argc, argv, "KSpell2Test");
+
+ QTextEdit *test = new QTextEdit();
+ KSpell2::Highlighter *hl = new KSpell2::Highlighter( test );
+ Q_UNUSED( hl );
+ app.setMainWidget( test );
+ test->show();
+
+ return app.exec();
+}