- void testRemoveAt() {
- int capacity = 16;
- int blocksize = 16;
- int maxBlocksize = 1024*1024;
- bool sorted = true;
- CStringInt table ( capacity, blocksize, maxBlocksize, ! sorted );
- DynBuffer buffer;
- for ( int ix = 0; ix < 1024; ix++ ) {
- buffer.clear().appendInt ( ix );
- table.add ( buffer.str() );
- }
- int count = 1024;
- checkE(count, table.count());
- for ( int ix = 1020; ix >= 3; ix-- ) {
- table.removeAt ( ix );
- if (--count != table.count())
- checkE(count, table.count());
- }
- table.dump("reduced table:");
- checkE ( count, table.count() );
- for ( int ix = 0; ix < 3; ix++ ) {
- buffer.clear().appendInt ( ix );
- checkE ( buffer.str(), table.get ( ix ) );
- }
- for ( int ix = 3; ix < table.count(); ix++ ) {
- buffer.clear().appendInt ( ix + 1020 - 3 + 1 );
- checkE ( buffer.str(), table.get ( ix ) );
- }
- }
- void testSorted() {
- int capacity = 16;
- int blocksize = 16;
- int maxBlocksize = 1024*1024;
- bool sorted = true;
- CStringInt table ( capacity, blocksize, maxBlocksize, ! sorted );
- checkF ( table.sorted() );
- table.setSorted ( sorted );
- checkT ( table.sorted() );
- }
- void testSetSorted() {
- int capacity = 16;
- int blocksize = 16;
- int maxBlocksize = 1024*1024;
- bool sorted = true;
- CStringInt table ( capacity, blocksize, maxBlocksize, sorted );
- checkT ( table.sorted() );
- table.setSorted ( !sorted );
- checkF ( table.sorted() );
- }