diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeui/tests/kaccelgentest.cpp | |
download | tdelibs-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 'kdeui/tests/kaccelgentest.cpp')
-rw-r--r-- | kdeui/tests/kaccelgentest.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/kdeui/tests/kaccelgentest.cpp b/kdeui/tests/kaccelgentest.cpp new file mode 100644 index 000000000..d619bdfba --- /dev/null +++ b/kdeui/tests/kaccelgentest.cpp @@ -0,0 +1,51 @@ +#include "kaccelgen.h" + +#include <qstringlist.h> + +#include <iostream> + +using std::cout; +using std::endl; + +void check( const QString &what, const QStringList &expected, const QStringList &received ) +{ + cout << "Testing " << what.latin1() << ": "; + if ( expected == received ) { + cout << "ok" << endl; + } else { + cout << "ERROR!" << endl; + cout << "Expected: " << expected.join( "," ).latin1() << endl; + cout << "Received: " << received.join( "," ).latin1() << endl; + } +} + +int main() +{ + QStringList input; + input << "foo" << "bar item" << "&baz" << "bif" << "boz" << "boz 2" + << "yoyo && dyne"; + + QStringList expected; + expected << "&foo" << "bar &item" << "&baz" << "bif" << "b&oz" << "boz &2" + << "&yoyo && dyne"; + + QStringList output; + KAccelGen::generate( input, output ); + check( "QStringList value generation", expected, output ); + + QMap<QString,QString> map; + for (QStringList::ConstIterator it = input.begin(); it != input.end(); ++it) { + map.insert(*it, *it); + } + input.sort(); + expected.clear(); + KAccelGen::generate( input, expected ); + + output.clear(); + KAccelGen::generateFromValues( map, output ); + check( "map value generation", expected, output ); + + output.clear(); + KAccelGen::generateFromKeys( map, output ); + check( "map key generation", expected, output ); +} |