From 738d62e0b94ba928f92df246eca1627ecabbcac2 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 23 Nov 2023 20:37:25 +0100 Subject: [PATCH] hoa: do not output empty highlighting maps * spot/twaalgos/hoa.cc: Here. * tests/python/parsetgba.py: Test it. --- spot/twaalgos/hoa.cc | 6 ++++-- tests/python/parsetgba.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/spot/twaalgos/hoa.cc b/spot/twaalgos/hoa.cc index 7ad37db28..902af0007 100644 --- a/spot/twaalgos/hoa.cc +++ b/spot/twaalgos/hoa.cc @@ -762,7 +762,8 @@ namespace spot if (v1_1) { if (auto hstates = aut->get_named_prop - >("highlight-states")) + >("highlight-states"); + hstates && !hstates->empty()) { os << "spot.highlight.states:"; for (auto& p: *hstates) @@ -770,7 +771,8 @@ namespace spot os << nl; } if (auto hedges = aut->get_named_prop - >("highlight-edges")) + >("highlight-edges"); + hedges && !hedges->empty()) { // Numbering edges is a delicate process. The // "highlight-edges" property uses edges numbers that are diff --git a/tests/python/parsetgba.py b/tests/python/parsetgba.py index ad657dfcc..3964ed28d 100755 --- a/tests/python/parsetgba.py +++ b/tests/python/parsetgba.py @@ -123,3 +123,26 @@ State: 4 {0} [1] 4 [2] 4 --END--""") +a3.highlight_edges([5, 6], None) +tc.assertEqual(a3.to_str("hoa", "1.1"), """HOA: v1.1 +States: 5 +Start: 0 +AP: 3 "a" "b" "c" +acc-name: Buchi +Acceptance: 1 Inf(0) +properties: trans-labels explicit-labels state-acc !complete +properties: !deterministic exist-branch +--BODY-- +State: 0 +[0] 1 +[0] 2 +State: 1 +[0] 3 +State: 2 +[0] 4 +State: 3 {0} +[0] 3 +State: 4 {0} +[1] 4 +[2] 4 +--END--""")