mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 04:03:39 +00:00
update heap unit tests (#7324)
* new heap invariants * change ENSURE to SASSERT for unit test heap * change SASSERT to VERIFY * update heap tests * update * remove one invariant
This commit is contained in:
parent
fce4b36dad
commit
d2fc085b8c
|
@ -27,7 +27,7 @@ struct lt_proc { bool operator()(int v1, int v2) const { return v1 < v2; } };
|
||||||
//struct int_hash_proc { unsigned operator()(int v) const { std::cout << "hash " << v << "\n"; VERIFY(v >= 0); return v; }};
|
//struct int_hash_proc { unsigned operator()(int v) const { std::cout << "hash " << v << "\n"; VERIFY(v >= 0); return v; }};
|
||||||
//typedef int_hashtable<int_hash_proc, default_eq<int> > int_set;
|
//typedef int_hashtable<int_hash_proc, default_eq<int> > int_set;
|
||||||
typedef heap<lt_proc> int_heap;
|
typedef heap<lt_proc> int_heap;
|
||||||
#define N 10000
|
#define N 100
|
||||||
|
|
||||||
static random_gen heap_rand(1);
|
static random_gen heap_rand(1);
|
||||||
|
|
||||||
|
@ -146,4 +146,3 @@ void tst_heap() {
|
||||||
tst2();
|
tst2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,19 @@ class heap : private LT {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_invariant_core(int idx) const {
|
bool check_invariant_core(int idx) const {
|
||||||
|
|
||||||
|
// Check that m_values starts with a dummy value at index 0.
|
||||||
|
if (m_values.empty() || m_values[0] != -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// // All indices in m_value2indices that are not used in m_values should be 0
|
||||||
|
// for (int val = 0; val < static_cast<int>(m_value2indices.size()); ++val) {
|
||||||
|
// if (std::find(m_values.begin(), m_values.end(), val) == m_values.end() && m_value2indices[val] != 0) {
|
||||||
|
// return false; // Unused indices should have a 0 value
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (idx < static_cast<int>(m_values.size())) {
|
if (idx < static_cast<int>(m_values.size())) {
|
||||||
SASSERT(m_value2indices[m_values[idx]] == idx);
|
SASSERT(m_value2indices[m_values[idx]] == idx);
|
||||||
SASSERT(parent(idx) == 0 || !less_than(m_values[idx], m_values[parent(idx)]));
|
SASSERT(parent(idx) == 0 || !less_than(m_values[idx], m_values[parent(idx)]));
|
||||||
|
|
Loading…
Reference in a new issue