Skip to content

Commit

Permalink
Improve representation of cardinality
Browse files Browse the repository at this point in the history
  • Loading branch information
Aonokishi committed Sep 17, 2024
1 parent 3f958cc commit 8783bd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cfmtoolbox/plugins/uvl_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def serialize_constraint(feature: Feature, cardinality: Cardinality) -> str:
if interval.lower == interval.upper:
return f"({feature.name} = {interval.lower})"

if interval.upper is None:
return f"({feature.name} >= {interval.lower})"

return (
f"(({feature.name} >= {interval.lower}) & ({feature.name} <= {interval.upper}))"
)
Expand Down
1 change: 1 addition & 0 deletions tests/plugins/test_uvl_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def test_serialize_features():
["constraint", "expectation"],
[
(Cardinality([Interval(1, 1)]), "(Sandwich = 1)"),
(Cardinality([Interval(1, None)]), "(Sandwich >= 1)"),
(Cardinality([Interval(1, 2)]), "((Sandwich >= 1) & (Sandwich <= 2))"),
],
)
Expand Down

0 comments on commit 8783bd0

Please sign in to comment.