mirror of
https://github.com/Z3Prover/z3
synced 2025-08-07 03:31:23 +00:00
update
This commit is contained in:
parent
f9f82bcc64
commit
56f216644e
1 changed files with 12 additions and 15 deletions
|
@ -38,7 +38,7 @@ static void tst1() {
|
||||||
for (int i = 0; i < N * 3; i++) {
|
for (int i = 0; i < N * 3; i++) {
|
||||||
int val = heap_rand() % N;
|
int val = heap_rand() % N;
|
||||||
if (!h.contains(val)) {
|
if (!h.contains(val)) {
|
||||||
VERIFY(!t.contains(val));
|
ENSURE(!t.contains(val));
|
||||||
h.insert(val);
|
h.insert(val);
|
||||||
t.insert(val);
|
t.insert(val);
|
||||||
}
|
}
|
||||||
|
@ -46,26 +46,26 @@ static void tst1() {
|
||||||
if (!t.contains(val)) {
|
if (!t.contains(val)) {
|
||||||
for (int v : t) std::cout << v << "\n";
|
for (int v : t) std::cout << v << "\n";
|
||||||
}
|
}
|
||||||
VERIFY(t.contains(val));
|
ENSURE(t.contains(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VERIFY(h.check_invariant());
|
ENSURE(h.check_invariant());
|
||||||
for (int v : t) {
|
for (int v : t) {
|
||||||
VERIFY(h.contains(v));
|
ENSURE(h.contains(v));
|
||||||
}
|
}
|
||||||
while (!h.empty()) {
|
while (!h.empty()) {
|
||||||
int m1 = h.min_value();
|
int m1 = h.min_value();
|
||||||
int m2 = h.erase_min();
|
int m2 = h.erase_min();
|
||||||
(void)m1;
|
(void)m1;
|
||||||
(void)m2;
|
(void)m2;
|
||||||
VERIFY(m1 == m2);
|
ENSURE(m1 == m2);
|
||||||
VERIFY(-1 < m2);
|
ENSURE(-1 < m2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int g_value[N];
|
int g_value[N];
|
||||||
|
|
||||||
struct lt_proc2 { bool operator()(int v1, int v2) const { VERIFY(v1 < N && v2 < N); return g_value[v1] < g_value[v2]; } };
|
struct lt_proc2 { bool operator()(int v1, int v2) const { ENSURE(v1 < N && v2 < N); return g_value[v1] < g_value[v2]; } };
|
||||||
typedef heap<lt_proc2> int_heap2;
|
typedef heap<lt_proc2> int_heap2;
|
||||||
|
|
||||||
static void init_values() {
|
static void init_values() {
|
||||||
|
@ -89,7 +89,7 @@ static void tst2() {
|
||||||
for (int i = 0; i < N * 10; i++) {
|
for (int i = 0; i < N * 10; i++) {
|
||||||
|
|
||||||
// if (i % 1 == 0) std::cout << "i: " << i << std::endl;
|
// if (i % 1 == 0) std::cout << "i: " << i << std::endl;
|
||||||
// if (i % 1000 == 0) std::cout << "i: " << i << std::endl;
|
if (i % 1000 == 0) std::cout << "i: " << i << std::endl;
|
||||||
int cmd = heap_rand() % 10;
|
int cmd = heap_rand() % 10;
|
||||||
if (cmd <= 3) {
|
if (cmd <= 3) {
|
||||||
// insert
|
// insert
|
||||||
|
@ -98,7 +98,7 @@ static void tst2() {
|
||||||
TRACE("heap", tout << "inserting: " << val << "\n";);
|
TRACE("heap", tout << "inserting: " << val << "\n";);
|
||||||
h.insert(val);
|
h.insert(val);
|
||||||
TRACE("heap", dump_heap(h, tout););
|
TRACE("heap", dump_heap(h, tout););
|
||||||
VERIFY(h.contains(val));
|
ENSURE(h.contains(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd <= 6) {
|
else if (cmd <= 6) {
|
||||||
|
@ -107,7 +107,7 @@ static void tst2() {
|
||||||
TRACE("heap", tout << "removing: " << val << "\n";);
|
TRACE("heap", tout << "removing: " << val << "\n";);
|
||||||
h.erase(val);
|
h.erase(val);
|
||||||
TRACE("heap", dump_heap(h, tout););
|
TRACE("heap", dump_heap(h, tout););
|
||||||
VERIFY(!h.contains(val));
|
ENSURE(!h.contains(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cmd <= 8) {
|
else if (cmd <= 8) {
|
||||||
|
@ -128,12 +128,10 @@ static void tst2() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VERIFY(h.check_invariant());
|
ENSURE(h.check_invariant());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VERIFY(h.check_invariant());
|
ENSURE(h.check_invariant());
|
||||||
h.reset();
|
|
||||||
VERIFY(h.check_invariant());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_heap() {
|
void tst_heap() {
|
||||||
|
@ -148,4 +146,3 @@ void tst_heap() {
|
||||||
tst2();
|
tst2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue