summaryrefslogtreecommitdiff
path: root/selftest.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <[email protected]>2016-06-21 07:49:46 -0700
committerAdam Ierymenko <[email protected]>2016-06-21 07:49:46 -0700
commit0c05b2cb50330a3b5c97c765db62e961e3c2408f (patch)
tree39af8c425ad3ba36056d3c69064100dc5be35c7b /selftest.cpp
parentb2d048aa0e01a350eaf524cc752ca5fa9a5a1140 (diff)
Comment cleanup and fuzzing improvements.
Diffstat (limited to 'selftest.cpp')
-rw-r--r--selftest.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/selftest.cpp b/selftest.cpp
index 0f777dfd..f712afd3 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -806,21 +806,22 @@ static int testOther()
}
int foo = 0;
volatile int *volatile bar = &foo; // force compiler not to optimize out test.get() below
- for(int k=0;k<100;++k) {
+ for(int k=0;k<200;++k) {
int r = rand() % 8194;
unsigned char tmp[8194];
for(int q=0;q<r;++q)
- tmp[q] = (unsigned char)((rand() % 254) + 1);
- tmp[r] = 0;
+ tmp[q] = (unsigned char)((rand() % 254) + 1); // don't put nulls since those will always just terminate scan
+ tmp[r] = (r % 32) ? (char)(rand() & 0xff) : (char)0; // every 32nd iteration don't terminate the string maybe...
Dictionary<8194> test((const char *)tmp);
for(unsigned int q=0;q<100;++q) {
- char tmp[16];
- Utils::snprintf(tmp,16,"%.8lx",(unsigned long)rand());
- char value[128];
- *bar = test.get(tmp,value,sizeof(value));
+ char tmp[128];
+ for(unsigned int x=0;x<128;++x)
+ tmp[x] = (char)(rand() & 0xff);
+ char value[8194];
+ *bar += test.get(tmp,value,sizeof(value));
}
}
- std::cout << "PASS" << std::endl;
+ std::cout << "PASS (junk value to prevent optimization-out of test: " << foo << ")" << std::endl;
return 0;
}