Commit 0e681ed0 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

acc: improve diagnostics for algorithms that use too many colors

* spot/twa/acc.hh (acc_cond::mark_t): Diagnose mark_t with set numbers
that are too larges.
* tests/python/except.py: Adjust.
* tests/core/acc.cc: Remove most of asserts, as those can be disabled,
and adjust expected exception.
parent f3186448
......@@ -102,7 +102,10 @@ namespace spot
: mark_t(_value_t::zero())
{
for (iterator i = begin; i != end; ++i)
set(*i);
if (SPOT_LIKELY(*i < SPOT_MAX_ACCSETS))
set(*i);
else
report_too_many_sets();
}
/// Create a mark_t from a list of set numbers.
......
......@@ -53,6 +53,17 @@ static void print(const std::vector<std::vector<int>>& res)
}
}
static void expect(const std::exception& e, const char* prefix)
{
if (std::strncmp(e.what(), "Too many acceptance sets used.",
strlen(prefix)))
{
std::cerr << "exception: " << e.what() << '\n';
std::cerr << "expected: " << prefix << '\n';
abort();
}
}
int main()
{
spot::acc_cond ac(4);
......@@ -189,7 +200,7 @@ int main()
}
catch (const std::runtime_error& e)
{
assert(!std::strncmp(e.what(), "Too many acceptance sets used.", 30));
expect(e, "Too many acceptance sets used.");
}
#if SPOT_DEBUG
......@@ -204,7 +215,7 @@ int main()
}
catch (const std::runtime_error& e)
{
assert(!std::strncmp(e.what(), "Too many acceptance sets used.", 30));
expect(e, "Too many acceptance sets used.");
}
try
......@@ -214,17 +225,17 @@ int main()
}
catch (const std::runtime_error& e)
{
assert(!std::strncmp(e.what(), "Too many acceptance sets used.", 30));
expect(e, "Too many acceptance sets used.");
}
#endif
try
{
spot::acc_cond::mark_t m{spot::acc_cond::mark_t::max_accsets()};
}
catch (const std::runtime_error& e)
{
assert(!std::strcmp(e.what(), "bit index is out of bounds"));
expect(e, "Too many acceptance sets used.");
}
#endif
return 0;
}
......@@ -169,7 +169,7 @@ else:
try:
m = spot.mark_t([0, n, 1])
except RuntimeError as e:
assert "bit index is out of bounds" in str(e)
assert "Too many acceptance sets used. The limit is" in str(e)
else:
report_missing_exception()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment