You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
15 years ago
|
#include "kaccelgen.h"
|
||
|
|
||
15 years ago
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
|
#include <iostream>
|
||
|
|
||
|
using std::cout;
|
||
|
using std::endl;
|
||
|
|
||
15 years ago
|
void check( const TQString &what, const TQStringList &expected, const TQStringList &received )
|
||
15 years ago
|
{
|
||
|
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()
|
||
|
{
|
||
15 years ago
|
TQStringList input;
|
||
15 years ago
|
input << "foo" << "bar item" << "&baz" << "bif" << "boz" << "boz 2"
|
||
|
<< "yoyo && dyne";
|
||
|
|
||
15 years ago
|
TQStringList expected;
|
||
15 years ago
|
expected << "&foo" << "bar &item" << "&baz" << "bif" << "b&oz" << "boz &2"
|
||
|
<< "&yoyo && dyne";
|
||
|
|
||
15 years ago
|
TQStringList output;
|
||
15 years ago
|
KAccelGen::generate( input, output );
|
||
15 years ago
|
check( "TQStringList value generation", expected, output );
|
||
15 years ago
|
|
||
15 years ago
|
TQMap<TQString,TQString> map;
|
||
|
for (TQStringList::ConstIterator it = input.begin(); it != input.end(); ++it) {
|
||
15 years ago
|
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 );
|
||
|
}
|