mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-29 04:06:40 +00:00
Use lexicographical comparison in ESM3ExteriorCellRefId::operator<
This commit is contained in:
parent
8cd5b91b4a
commit
bd10becb65
2 changed files with 15 additions and 2 deletions
|
@ -212,6 +212,14 @@ namespace ESM
|
||||||
EXPECT_NE(hash(a), hash(b));
|
EXPECT_NE(hash(a), hash(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(ESMRefIdTest, esm3ExteriorCellHasLexicographicalOrder)
|
||||||
|
{
|
||||||
|
const RefId a = RefId::esm3ExteriorCell(0, 0);
|
||||||
|
const RefId b = RefId::esm3ExteriorCell(1, 0);
|
||||||
|
EXPECT_LT(a, b);
|
||||||
|
EXPECT_TRUE(!(b < a));
|
||||||
|
}
|
||||||
|
|
||||||
struct ESMRefIdToStringTest : TestWithParam<std::pair<RefId, std::string>>
|
struct ESMRefIdToStringTest : TestWithParam<std::pair<RefId, std::string>>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,9 +28,14 @@ namespace ESM
|
||||||
int32_t getX() const { return mX; }
|
int32_t getX() const { return mX; }
|
||||||
int32_t getY() const { return mY; }
|
int32_t getY() const { return mY; }
|
||||||
|
|
||||||
constexpr bool operator==(ESM3ExteriorCellRefId rhs) const noexcept { return mX == rhs.mX && mY == rhs.mY; }
|
friend inline constexpr auto tie(const ESM3ExteriorCellRefId& value) noexcept
|
||||||
|
{
|
||||||
|
return std::tie(value.mX, value.mY);
|
||||||
|
}
|
||||||
|
|
||||||
constexpr bool operator<(ESM3ExteriorCellRefId rhs) const noexcept { return mX < rhs.mX && mY < rhs.mY; }
|
constexpr bool operator==(ESM3ExteriorCellRefId rhs) const noexcept { return tie(*this) == tie(rhs); }
|
||||||
|
|
||||||
|
constexpr bool operator<(ESM3ExteriorCellRefId rhs) const noexcept { return tie(*this) < tie(rhs); }
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value);
|
friend std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue