diff --git a/include/dpp/role.h b/include/dpp/role.h index 0917fa15a4..42119c1569 100644 --- a/include/dpp/role.h +++ b/include/dpp/role.h @@ -324,19 +324,8 @@ class DPP_EXPORT role : public managed, public json_interface { * @param lhs first role to compare * @param rhs second role to compare * @return true if lhs is less than rhs - * - * @throws std::invalid_argument when roles of two different guilds are passed */ friend inline bool operator< (const role& lhs, const role& rhs) { - if (lhs.guild_id != rhs.guild_id) { - throw std::invalid_argument("cannot compare roles from two different guilds"); - } - - // the @everyone role is always the lowest role in hierarchy - if (lhs.id == lhs.guild_id) { - return rhs.id != lhs.guild_id; - } - if (lhs.position == rhs.position) { // the higher the IDs are, the lower the position return lhs.id > rhs.id; @@ -351,8 +340,6 @@ class DPP_EXPORT role : public managed, public json_interface { * @param lhs first role to compare * @param rhs second role to compare * @return true if lhs is greater than rhs - * - * @throws std::invalid_argument when roles of two different guilds are passed */ friend inline bool operator> (const role& lhs, const role& rhs) { return !(lhs < rhs); @@ -365,7 +352,7 @@ class DPP_EXPORT role : public managed, public json_interface { * @return true if is equal to other */ inline bool operator== (const role& other) const { - return this->position == other.position; + return this->id == other.id; } /** @@ -375,7 +362,7 @@ class DPP_EXPORT role : public managed, public json_interface { * @return true if is not equal to other */ inline bool operator!= (const role& other) const { - return this->position != other.position; + return this->id != other.id; } /** diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 3182d91c24..b85b9386ab 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -345,23 +345,14 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b { set_test(ROLE_COMPARE, false); dpp::role role_1, role_2; + role_1.id = 99; role_1.position = 1; role_1.guild_id = 123; + role_1.id = 98; role_2.position = 2; role_2.guild_id = 123; set_test(ROLE_COMPARE, role_1 < role_2 && !(role_1 > role_2) && role_1 != role_2); } - { - set_test(ROLE_COMPARE_CONSIDERING_EVERYONE_ROLE, false); - dpp::role role_1, role_2; - role_1.id = 123; - role_1.position = 2; - role_1.guild_id = 123; - role_2.id = 124; - role_2.position = 2; - role_2.guild_id = 123; - set_test(ROLE_COMPARE_CONSIDERING_EVERYONE_ROLE, role_1 < role_2 && !(role_1 > role_2)); - } { set_test(ROLE_COMPARE_CONSIDERING_ID, false); dpp::role role_1, role_2; diff --git a/src/unittest/test.h b/src/unittest/test.h index edb942c40a..8c0d1e1192 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -206,7 +206,6 @@ DPP_TEST(UTILITY_CDN_ENDPOINT_URL_HASH, "utility::cdn_endpoint_url_hash", tf_off DPP_TEST(STICKER_GET_URL, "sticker::get_url aka utility::cdn_endpoint_url_sticker", tf_offline); DPP_TEST(EMOJI_GET_URL, "emoji::get_url", tf_offline); DPP_TEST(ROLE_COMPARE, "role::operator<", tf_offline); -DPP_TEST(ROLE_COMPARE_CONSIDERING_EVERYONE_ROLE, "role::operator<", tf_offline); DPP_TEST(ROLE_COMPARE_CONSIDERING_ID, "role::operator<", tf_offline); DPP_TEST(ROLE_CREATE, "cluster::role_create", tf_online); DPP_TEST(ROLE_EDIT, "cluster::role_edit", tf_online);