1
Fork 0
turbonss/cxxmph/mphtable_test.cc

31 lines
743 B
C++

#include <cassert>
#include <string>
#include <vector>
#include "mphtable.h"
using std::string;
using std::vector;
using cxxmph::MPHTable;
int main(int argc, char** argv) {
vector<string> keys;
keys.push_back("davi");
keys.push_back("paulo");
keys.push_back("joao");
keys.push_back("maria");
keys.push_back("bruno");
MPHTable mphtable;
assert(mphtable.Reset(keys.begin(), keys.end()));
vector<int> ids;
for (vector<int>::size_type i = 0; i < keys.size(); ++i) {
ids.push_back(mphtable.index(keys[i]));
cerr << " " << *(ids.end() - 1);
}
cerr << endl;
sort(ids.begin(), ids.end());
for (vector<int>::size_type i = 0; i < ids.size(); ++i) assert(ids[i] == static_cast<vector<int>::value_type>(i));
}