3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-03 04:33:28 +00:00

test: replace SASSERT with ENSURE, remove Windows-only guards (#10086)

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>
This commit is contained in:
Copilot 2026-07-11 21:14:59 -07:00 committed by GitHub
parent b0a77d2a58
commit c4b0fe33bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 205 additions and 219 deletions

View file

@ -51,7 +51,7 @@ static void test1() {
g.propagate();
TRACE(bv, tout << "after propagate\n" << g << "\n");
std::cout << g << "\n";
SASSERT(nx->get_root() == ny->get_root());
ENSURE(nx->get_root() == ny->get_root());
}
// propagate values down
@ -70,10 +70,10 @@ static void test2() {
expr_ref xx(bv.mk_concat(x1, bv.mk_concat(x2, x3)), m);
g.merge(get_node(g, bv, xx), get_node(g, bv, bv.mk_numeral((1 << 27) + (1 << 17) + (1 << 3), 32)), nullptr);
g.propagate();
SASSERT(get_node(g, bv, x1)->get_root()->interpreted());
SASSERT(get_node(g, bv, x2)->get_root()->interpreted());
SASSERT(get_node(g, bv, x3)->get_root()->interpreted());
SASSERT(get_node(g, bv, x)->get_root()->interpreted());
ENSURE(get_node(g, bv, x1)->get_root()->interpreted());
ENSURE(get_node(g, bv, x2)->get_root()->interpreted());
ENSURE(get_node(g, bv, x3)->get_root()->interpreted());
ENSURE(get_node(g, bv, x)->get_root()->interpreted());
}
@ -96,9 +96,9 @@ static void test3() {
g.merge(get_node(g, bv, x1), get_node(g, bv, bv.mk_numeral(2, 8)), nullptr);
g.merge(get_node(g, bv, x2), get_node(g, bv, bv.mk_numeral(8, 8)), nullptr);
g.propagate();
SASSERT(get_node(g, bv, bv.mk_concat(x1, x2))->get_root()->interpreted());
SASSERT(get_node(g, bv, x1)->get_root()->interpreted());
SASSERT(get_node(g, bv, x2)->get_root()->interpreted());
ENSURE(get_node(g, bv, bv.mk_concat(x1, x2))->get_root()->interpreted());
ENSURE(get_node(g, bv, x1)->get_root()->interpreted());
ENSURE(get_node(g, bv, x2)->get_root()->interpreted());
}
// propagate extract up
@ -121,7 +121,7 @@ static void test4() {
g.merge(get_node(g, bv, x1), get_node(g, bv, a), nullptr);
g.propagate();
TRACE(bv, tout << g << "\n");
SASSERT(get_node(g, bv, bv.mk_extract(23, 8, x))->get_root() == get_node(g, bv, y)->get_root());
ENSURE(get_node(g, bv, bv.mk_extract(23, 8, x))->get_root() == get_node(g, bv, y)->get_root());
}
// iterative slicing