3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-08 08:15:47 +00:00

ensure that assertions within the unit tests are exercised in all build modes, remove special handling of SASSERT for release mode #1163

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-07-26 20:28:55 -07:00
parent 3f8b63f5a8
commit b1298d7bde
67 changed files with 1277 additions and 1285 deletions

View file

@ -23,10 +23,6 @@ Revision History:
#include"hashtable.h"
#ifndef Z3DEBUG
#undef SASSERT
#define SASSERT(COND) { if (!(COND)) std::cerr << "ERROR: " << #COND << "\n"; } ((void) 0)
#endif
struct int_hash_proc { unsigned operator()(int x) const { return x * 3; } };
typedef int_hashtable<int_hash_proc, default_eq<int> > int_set;
@ -48,16 +44,16 @@ static void tst1() {
int v = rand() % (N / 2);
h1.insert(v);
vals[i] = v;
SASSERT(contains(h1, v));
ENSURE(contains(h1, v));
}
std::cout << "step1\n"; std::cout.flush();
for (int i = 1; i < N; i ++) {
SASSERT(contains(h1, vals[i]));
ENSURE(contains(h1, vals[i]));
}
std::cout << "step2\n"; std::cout.flush();
for (int i = 1; i < N; i += 2) {
h1.erase(vals[i]);
SASSERT(!contains(h1, vals[i]));
ENSURE(!contains(h1, vals[i]));
}
std::cout << "step3\n"; std::cout.flush();
for (int i = 1; i < N; i += 2) {
@ -65,7 +61,7 @@ static void tst1() {
}
std::cout << "step4\n"; std::cout.flush();
for (int i = 1; i < N; i ++) {
SASSERT(contains(h1, vals[i]));
ENSURE(contains(h1, vals[i]));
}
}
@ -78,19 +74,19 @@ static void tst2() {
if (rand() % 3 == 2) {
h1.erase(v);
h2.erase(v);
SASSERT(!contains(h1, v));
ENSURE(!contains(h1, v));
}
else {
h1.insert(v);
h2.insert(v);
SASSERT(contains(h1, v));
ENSURE(contains(h1, v));
}
}
{
safe_int_set::iterator it = h2.begin();
safe_int_set::iterator end = h2.end();
for(; it != end; ++it) {
SASSERT(contains(h1, *it));
ENSURE(contains(h1, *it));
}
}
{
@ -98,12 +94,12 @@ static void tst2() {
int_set::iterator end = h1.end();
int n = 0;
for (; it != end; ++it) {
SASSERT(contains(h1, *it));
ENSURE(contains(h1, *it));
n++;
}
SASSERT(n == h1.size());
ENSURE(n == h1.size());
}
SASSERT(h1.size() == h2.size());
ENSURE(h1.size() == h2.size());
// std::cout << "size: " << h1.size() << ", capacity: " << h1.capacity() << "\n"; std::cout.flush();
}
@ -114,13 +110,13 @@ static void tst3() {
h1.insert(30);
h1.erase(20);
int_set h2(h1);
SASSERT(h1.contains(10));
SASSERT(!h1.contains(20));
SASSERT(h1.contains(30));
SASSERT(h2.contains(10));
SASSERT(!h2.contains(20));
SASSERT(h2.contains(30));
SASSERT(h2.size() == 2);
ENSURE(h1.contains(10));
ENSURE(!h1.contains(20));
ENSURE(h1.contains(30));
ENSURE(h2.contains(10));
ENSURE(!h2.contains(20));
ENSURE(h2.contains(30));
ENSURE(h2.size() == 2);
}
void tst_hashtable() {