+void test_static_sequence(uint * symbols, uint n, static_sequence * ss) {
+ cout << "Size: " << ss->size() << endl;
+ uint max_v=0;
+ for(uint i=0;i<n;i++)
+ max_v = max(max_v,symbols[i]);
+ uint * occ = new uint[max_v+1];
+ for(uint i=0;i<=max_v;i++)
+ occ[i] = 0;
+ bool error = false;
+ for(uint i=0;i<n && !error;i++) {
+ if(i!=0 && i%max(1,(n-1)/100)==0) { cout << "."; cout.flush(); }
+ if(i!=0 && i%max(1,(n-1)/10)==0) cout << endl;
+ occ[symbols[i]]++;
+ uint a = ss->access(i);
+ uint r = ss->rank(symbols[i],i);
+ uint s = ss->select(symbols[i],occ[symbols[i]]);
+ uint rM1 = (i==0)?0:ss->rank(symbols[i],i-1);
+ if(r!=occ[symbols[i]]) {
+ cout << "Error in rank for symbol " << symbols[i] << " at position " << i << endl;
+ cout << "value: " << r << endl;
+ cout << "Expected: " << occ[symbols[i]] << endl;
+ error = true;
+ }
+ if(s!=i) {
+ cout << "Error in select for symbol " << symbols[i] << " at position " << occ[symbols[i]] << endl;
+ cout << "value: " << s << endl;
+ cout << "Expected: " << i << endl;
+ error = true;
+ }
+ if(a!=symbols[i]) {
+ cout << "Error in access at position " << i << endl;
+ cout << "value: " << a << endl;
+ cout << "Expected: " << symbols[i] << endl;
+ error = true;
+ }
+ if(rM1!=occ[symbols[i]]-1) {
+ cout << "Error in rankM1 for symbol " << symbols[i] << " at position " << i-1 << endl;
+ cout << "value: " << rM1 << endl;
+ cout << "Expected: " << occ[symbols[i]]-1 << endl;
+ error = true;
+ }
+ }
+ if(!error)
+ cout << "Test OK! It works :)" << endl;
+ delete [] occ;
+}
+