Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition: comparison operators #425

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading