word: throw an exception when printing an empty word

Fixes #146.

* spot/twaalgos/word.cc: Here.
* tests/python/word.ipynb: Add a test case.
This commit is contained in:
Alexandre Duret-Lutz 2016-03-08 14:22:58 +01:00
parent 7e2e4df1bb
commit cd661801df
2 changed files with 41 additions and 4 deletions

View file

@ -93,6 +93,8 @@ namespace spot
std::ostream&
operator<<(std::ostream& os, const twa_word& w)
{
if (w.cycle.empty())
throw std::runtime_error("a twa_word may not have an empty cycle");
auto d = w.get_dict();
if (!w.prefix.empty())
for (auto& i: w.prefix)
@ -100,7 +102,6 @@ namespace spot
bdd_print_formula(os, d, i);
os << "; ";
}
assert(!w.cycle.empty());
bool notfirst = false;
os << "cycle{";
for (auto& i: w.cycle)