Skip to content

Commit

Permalink
add relation enum to relation_t
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMG committed Jul 11, 2023
1 parent 2d35db6 commit 86c11ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/pardibaal/DBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ namespace pardibaal {
relation_t relation_t::superset() {return relation_t(false, false, true, false);}
relation_t relation_t::different() {return relation_t(false, false, false, true);}

relation_e relation_t::type() const {return is_equal() ? EQUAL : is_subset() ? SUBSET : is_superset() ? SUPERSET : DIFFERENT;}

bool relation_t::is_equal() const {return _is_equal;}
bool relation_t::is_subset() const {return _is_subset;}
bool relation_t::is_superset() const {return _is_superset;}
Expand Down
4 changes: 4 additions & 0 deletions src/pardibaal/DBM.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

namespace pardibaal {
class Federation;

enum relation_e {EQUAL, SUBSET, SUPERSET, DIFFERENT};
/**
* Relation struct
* represents the relation between two DBMs.
Expand All @@ -51,6 +53,8 @@ namespace pardibaal {
[[nodiscard]] static relation_t superset();
[[nodiscard]] static relation_t different();

[[nodiscard]] relation_e type() const;

[[nodiscard]] bool is_equal() const;
[[nodiscard]] bool is_subset() const;
[[nodiscard]] bool is_superset() const;
Expand Down
14 changes: 13 additions & 1 deletion test/DBM_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ BOOST_AUTO_TEST_CASE(relation_test_3) {
BOOST_CHECK(D2.is_superset(D1));
BOOST_CHECK(not D2.relation(D1).is_equal());
BOOST_CHECK(not D2.is_equal(D1));
BOOST_CHECK(not D1.is_equal(D2));

D1.assign(1, 10);

Expand All @@ -955,10 +956,21 @@ BOOST_AUTO_TEST_CASE(relation_test_4) {
DBM a(1), b(1);

a.future();

BOOST_CHECK(a.is_equal(b));
}

BOOST_AUTO_TEST_CASE(relation_t_test_1) {
DBM a(10), b(10);

a.future();

BOOST_CHECK(a.relation(b).type() == SUPERSET);

b.future();

BOOST_CHECK(a.relation(b).type() == EQUAL);
}

BOOST_AUTO_TEST_CASE(intersects_test_1) {
DBM dbm1(3);
DBM dbm2(3);
Expand Down

0 comments on commit 86c11ec

Please sign in to comment.