summaryrefslogtreecommitdiff
path: root/selftest.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-30 15:54:40 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-30 15:54:40 -0700
commit1b4cc4af5c7c0e47f73f3728ca36dc665d0e3224 (patch)
treedd314c01c1b48ace25c093fbd4345fa0112377bb /selftest.cpp
parent7382c328daa33b5ff21baf78ee022f23092cda3b (diff)
downloadinfinitytier-1b4cc4af5c7c0e47f73f3728ca36dc665d0e3224.tar.gz
infinitytier-1b4cc4af5c7c0e47f73f3728ca36dc665d0e3224.zip
Fix evil bug, and instrument/assert on some other stuff, and a bit of cleanup.
Diffstat (limited to 'selftest.cpp')
-rw-r--r--selftest.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/selftest.cpp b/selftest.cpp
index fa5eec0f..0787925f 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -593,23 +593,44 @@ static int testOther()
std::cout << "[other] Testing Hashtable... "; std::cout.flush();
{
Hashtable<uint64_t,std::string> ht;
- Hashtable<uint64_t,std::string> ht2;
std::map<uint64_t,std::string> ref; // assume std::map works correctly :)
for(int x=0;x<2;++x) {
- for(int i=0;i<25000;++i) {
+ for(int i=0;i<77777;++i) {
uint64_t k = rand();
while ((k == 0)||(ref.count(k) > 0))
++k;
std::string v("!");
for(int j=0;j<(int)(k % 64);++j)
v.push_back("0123456789"[rand() % 10]);
- ht.set(k,v);
ref[k] = v;
+ ht.set(0xffffffffffffffffULL,v);
+ std::string &vref = ht[k];
+ vref = v;
+ ht.erase(0xffffffffffffffffULL);
}
if (ht.size() != ref.size()) {
std::cout << "FAILED! (size mismatch, original)" << std::endl;
return -1;
}
+ {
+ Hashtable<uint64_t,std::string>::Iterator i(ht);
+ uint64_t *k = (uint64_t *)0;
+ std::string *v = (std::string *)0;
+ while(i.next(k,v)) {
+ if (ref.find(*k)->second != *v) {
+ std::cout << "FAILED! (data mismatch!)" << std::endl;
+ return -1;
+ }
+ }
+ }
+ for(std::map<uint64_t,std::string>::const_iterator i(ref.begin());i!=ref.end();++i) {
+ if (ht[i->first] != i->second) {
+ std::cout << "FAILED! (data mismatch!)" << std::endl;
+ return -1;
+ }
+ }
+
+ Hashtable<uint64_t,std::string> ht2;
ht2 = ht;
Hashtable<uint64_t,std::string> ht3(ht2);
if (ht2.size() != ref.size()) {
@@ -620,6 +641,7 @@ static int testOther()
std::cout << "FAILED! (size mismatch, copied)" << std::endl;
return -1;
}
+
for(std::map<uint64_t,std::string>::iterator i(ref.begin());i!=ref.end();++i) {
std::string *v = ht.get(i->first);
if (!v) {