Skip to content

Commit

Permalink
Merge pull request #425 from VeriFIT/transition-comparison
Browse files Browse the repository at this point in the history
Transition: comparison operators #patch
  • Loading branch information
Adda0 authored Jul 17, 2024
2 parents 8119129 + 2253cf7 commit bdcb62d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/mata/nfa/delta.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Transition {
Transition(const State source, const Symbol symbol, const State target)
: source(source), symbol(symbol), target(target) {}

bool operator==(const Transition& rhs) const { return source == rhs.source && symbol == rhs.symbol && target == rhs.target; }
auto operator<=>(const Transition&) const = default;
};

/**
Expand Down
15 changes: 15 additions & 0 deletions tests/nfa/delta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,18 @@ TEST_CASE("mata::nfa::Delta::add_symbols_to()") {
{ "0", 0 }, { "1", 1 }, { "2", 2 }, { "3", 3 }
});
}

TEST_CASE("Transition comparison") {
Transition tr1 {1, 2, 3};
Transition tr2 {1, 3, 1};
Transition tr3 {1, 2, 5};
Transition tr4 {1, 2, 1};
Transition tr5 {1, 2, 1};

CHECK(tr1 < tr2);
CHECK(tr2 >= tr3);
CHECK(tr3 >= tr1);
CHECK(tr4 < tr3);
CHECK(tr5 <= tr4);
CHECK(tr5 == tr4);
}

0 comments on commit bdcb62d

Please sign in to comment.