summaryrefslogtreecommitdiffstats
path: root/tdeui/tests/tdeaccelgentest.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-01 17:25:43 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-01 17:25:43 -0600
commitd888cfa39e8b38abe17f3d425d19cb8235136a79 (patch)
tree7ae5487b84106036fdb781beec26fab10678a595 /tdeui/tests/tdeaccelgentest.cpp
parentdeac2ca49faed824fe83066080714eb6d653615b (diff)
downloadtdelibs-d888cfa39e8b38abe17f3d425d19cb8235136a79.tar.gz
tdelibs-d888cfa39e8b38abe17f3d425d19cb8235136a79.zip
Fix FTBFS
Diffstat (limited to 'tdeui/tests/tdeaccelgentest.cpp')
-rw-r--r--tdeui/tests/tdeaccelgentest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tdeui/tests/tdeaccelgentest.cpp b/tdeui/tests/tdeaccelgentest.cpp
new file mode 100644
index 000000000..783a0f36f
--- /dev/null
+++ b/tdeui/tests/tdeaccelgentest.cpp
@@ -0,0 +1,51 @@
+#include "kaccelgen.h"
+
+#include <tqstringlist.h>
+
+#include <iostream>
+
+using std::cout;
+using std::endl;
+
+void check( const TQString &what, const TQStringList &expected, const TQStringList &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()
+{
+ TQStringList input;
+ input << "foo" << "bar item" << "&baz" << "bif" << "boz" << "boz 2"
+ << "yoyo && dyne";
+
+ TQStringList expected;
+ expected << "&foo" << "bar &item" << "&baz" << "bif" << "b&oz" << "boz &2"
+ << "&yoyo && dyne";
+
+ TQStringList output;
+ TDEAccelGen::generate( input, output );
+ check( "TQStringList value generation", expected, output );
+
+ TQMap<TQString,TQString> map;
+ for (TQStringList::ConstIterator it = input.begin(); it != input.end(); ++it) {
+ map.insert(*it, *it);
+ }
+ input.sort();
+ expected.clear();
+ TDEAccelGen::generate( input, expected );
+
+ output.clear();
+ TDEAccelGen::generateFromValues( map, output );
+ check( "map value generation", expected, output );
+
+ output.clear();
+ TDEAccelGen::generateFromKeys( map, output );
+ check( "map key generation", expected, output );
+}