From 195e0319d107b19deb39cc8d08c751df5c12de24 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Wed, 3 Sep 2025 17:18:13 -0500 Subject: [PATCH] chore(hash): ensure correct const declarations in HASHKEY classes --- storm/hash/Hashkey.cpp | 6 +++--- storm/hash/Hashkey.hpp | 6 +++--- test/Hash.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/storm/hash/Hashkey.cpp b/storm/hash/Hashkey.cpp index 5f860b0..f1d11f9 100644 --- a/storm/hash/Hashkey.cpp +++ b/storm/hash/Hashkey.cpp @@ -14,7 +14,7 @@ HASHKEY_PTR::HASHKEY_PTR(void* key) { this->m_key = key; } -bool HASHKEY_PTR::operator==(const HASHKEY_PTR& key) { +bool HASHKEY_PTR::operator==(const HASHKEY_PTR& key) const { return this->m_key == key.m_key; } @@ -44,7 +44,7 @@ HASHKEY_STR& HASHKEY_STR::operator=(const char* str) { return *this; } -bool HASHKEY_STR::operator==(const char* str) { +bool HASHKEY_STR::operator==(const char* str) const { return SStrCmp(this->m_str, str, STORM_MAX_STR) == 0; } @@ -53,6 +53,6 @@ HASHKEY_STRI& HASHKEY_STRI::operator=(const char* str) { return *this; } -bool HASHKEY_STRI::operator==(const char* str) { +bool HASHKEY_STRI::operator==(const char* str) const { return SStrCmpI(this->m_str, str, STORM_MAX_STR) == 0; } diff --git a/storm/hash/Hashkey.hpp b/storm/hash/Hashkey.hpp index 4df6115..bde3e8a 100644 --- a/storm/hash/Hashkey.hpp +++ b/storm/hash/Hashkey.hpp @@ -9,7 +9,7 @@ class HASHKEY_PTR { // Member functions HASHKEY_PTR(); HASHKEY_PTR(void* key); - bool operator==(const HASHKEY_PTR& key); + bool operator==(const HASHKEY_PTR& key) const; }; class HASHKEY_STR { @@ -22,14 +22,14 @@ class HASHKEY_STR { HASHKEY_STR(const char* str); ~HASHKEY_STR(); HASHKEY_STR& operator=(const char* str); - bool operator==(const char* str); + bool operator==(const char* str) const; }; class HASHKEY_STRI : public HASHKEY_STR { public: // Member functions HASHKEY_STRI& operator=(const char* str); - bool operator==(const char* str); + bool operator==(const char* str) const; }; class HASHKEY_NONE { diff --git a/test/Hash.cpp b/test/Hash.cpp index 41b0ac2..728052f 100644 --- a/test/Hash.cpp +++ b/test/Hash.cpp @@ -18,19 +18,19 @@ TEST_CASE("HASHKEY_PTR", "[hash]") { SECTION("constructs correctly") { HASHKEY_PTR key1; HASHKEY_PTR key2; - REQUIRE(key1.operator==(key2)); + REQUIRE(key1 == key2); void* ptr = reinterpret_cast(0xDEAFBEEF); HASHKEY_PTR key3 = { ptr }; HASHKEY_PTR key4 = { ptr }; - REQUIRE(key3.operator==(key4)); + REQUIRE(key3 == key4); } } TEST_CASE("HASHKEY_STR", "[hash]") { SECTION("constructs correctly") { HASHKEY_STR key = { "foo" }; - REQUIRE(key.operator==("foo")); + REQUIRE(key == "foo"); } }