mirror of
https://github.com/Z3Prover/z3
synced 2026-08-02 20:23:27 +00:00
Unit tests relied on `SASSERT()` which is a no-op in release builds (`DEBUG_CODE` wrapper), silently skipping all assertions outside debug mode. Several test files were also gated behind `#ifdef _WINDOWS`, making them dead code on Linux/macOS CI. ## Changes - **`SASSERT` → `ENSURE` in 20 test files (200 occurrences)**: `ENSURE` maps to `VERIFY` and always executes regardless of build type, ensuring test assertions are active in both debug and release builds. - **`src/test/diff_logic.cpp`**: Removed `#ifdef _WINDOWS` wrapping the entire file. No Windows-specific APIs were used; the guard only prevented compilation on non-Windows platforms. - **`src/test/dl_product_relation.cpp`**: Removed `#ifdef _WINDOWS` guard around `tst_dl_product_relation()`. The function body has no platform dependencies. - **`src/test/sat_local_search.cpp`**: Replaced `sscanf_s` (MSVC-specific) with portable `sscanf`; added return-value check to detect malformed input. Previously, `build_instance()` unconditionally returned `false` on non-Windows, making the SAT local search test a no-op on Linux/macOS. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
99 lines
1.9 KiB
C++
99 lines
1.9 KiB
C++
#include <iostream>
|
|
#include "util/scoped_vector.h"
|
|
|
|
void test_push_back_and_access() {
|
|
scoped_vector<int> sv;
|
|
sv.push_back(10);
|
|
|
|
sv.push_back(20);
|
|
|
|
ENSURE(sv.size() == 2);
|
|
ENSURE(sv[0] == 10);
|
|
ENSURE(sv[1] == 20);
|
|
|
|
std::cout << "test_push_back_and_access passed." << std::endl;
|
|
}
|
|
|
|
void test_scopes() {
|
|
scoped_vector<int> sv;
|
|
sv.push_back(10);
|
|
sv.push_back(20);
|
|
|
|
sv.push_scope();
|
|
sv.push_back(30);
|
|
sv.push_back(40);
|
|
|
|
ENSURE(sv.size() == 4);
|
|
ENSURE(sv[2] == 30);
|
|
ENSURE(sv[3] == 40);
|
|
|
|
sv.pop_scope(1);
|
|
|
|
std::cout << "test_scopes passed." << std::endl;
|
|
ENSURE(sv.size() == 2);
|
|
ENSURE(sv[0] == 10);
|
|
ENSURE(sv[1] == 20);
|
|
|
|
std::cout << "test_scopes passed." << std::endl;
|
|
}
|
|
|
|
void test_set() {
|
|
scoped_vector<int> sv;
|
|
sv.push_back(10);
|
|
sv.push_back(20);
|
|
|
|
sv.set(0, 30);
|
|
sv.set(1, 40);
|
|
|
|
ENSURE(sv.size() == 2);
|
|
ENSURE(sv[0] == 30);
|
|
ENSURE(sv[1] == 40);
|
|
|
|
sv.push_scope();
|
|
sv.set(0, 50);
|
|
ENSURE(sv[0] == 50);
|
|
sv.pop_scope(1);
|
|
ENSURE(sv[0] == 30);
|
|
|
|
std::cout << "test_set passed." << std::endl;
|
|
}
|
|
|
|
void test_pop_back() {
|
|
scoped_vector<int> sv;
|
|
sv.push_back(10);
|
|
sv.push_back(20);
|
|
|
|
ENSURE(sv.size() == 2);
|
|
sv.pop_back();
|
|
ENSURE(sv.size() == 1);
|
|
ENSURE(sv[0] == 10);
|
|
sv.pop_back();
|
|
ENSURE(sv.size() == 0);
|
|
|
|
std::cout << "test_pop_back passed." << std::endl;
|
|
}
|
|
|
|
void test_erase_and_swap() {
|
|
scoped_vector<int> sv;
|
|
sv.push_back(10);
|
|
sv.push_back(20);
|
|
sv.push_back(30);
|
|
|
|
sv.erase_and_swap(1);
|
|
|
|
ENSURE(sv.size() == 2);
|
|
ENSURE(sv[0] == 10);
|
|
ENSURE(sv[1] == 30);
|
|
|
|
std::cout << "test_erase_and_swap passed." << std::endl;
|
|
}
|
|
|
|
void tst_scoped_vector() {
|
|
test_push_back_and_access();
|
|
test_scopes();
|
|
test_set();
|
|
test_pop_back();
|
|
test_erase_and_swap();
|
|
|
|
std::cout << "All tests passed." << std::endl;
|
|
}
|