mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
replace macro with anonymous namespace function (#1394)
This commit is contained in:
parent
3deec6499d
commit
440dc8b88f
@ -116,27 +116,30 @@ TEST(MagicEnumTest, eGameMessageTypeTest) {
|
|||||||
delete Game::logger;
|
delete Game::logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ASSERT_EARRAY_SORTED(EARRAY_VAR)\
|
#define LOG_EARRAY(EARRAY_VAR, INDICE, ENTRY) LOG(#EARRAY_VAR"[%i] = %i, %s", INDICE, ENTRY, magic_enum::enum_name(ENTRY).data());
|
||||||
for (int i = 0; i < EARRAY_VAR->size(); i++) {\
|
|
||||||
const auto entryCurr = EARRAY_VAR->at(i).first;\
|
|
||||||
LOG_EARRAY(EARRAY_VAR, i, entryCurr);\
|
|
||||||
const auto entryNext = EARRAY_VAR->at(++i).first;\
|
|
||||||
LOG_EARRAY(EARRAY_VAR, i, entryNext);\
|
|
||||||
ASSERT_TRUE(entryCurr < entryNext);\
|
|
||||||
};\
|
|
||||||
|
|
||||||
#define LOG_EARRAY(EARRAY_VAR, INDICE, ENTRY)\
|
namespace {
|
||||||
LOG(#EARRAY_VAR"[%i] = %i, %s", INDICE, ENTRY, magic_enum::enum_name(ENTRY).data());
|
template <typename T>
|
||||||
|
void AssertEnumArraySorted(const T& eArray) {
|
||||||
|
for (int i = 0; i < eArray->size(); ++i) {
|
||||||
|
const auto entryCurr = eArray->at(i).first;
|
||||||
|
LOG_EARRAY(eArray, i, entryCurr);
|
||||||
|
const auto entryNext = eArray->at(++i).first;
|
||||||
|
LOG_EARRAY(eArray, i, entryNext);
|
||||||
|
ASSERT_TRUE(entryCurr < entryNext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test that the magic enum arrays are pre-sorted
|
// Test that the magic enum arrays are pre-sorted
|
||||||
TEST(MagicEnumTest, ArraysAreSorted) {
|
TEST(MagicEnumTest, ArraysAreSorted) {
|
||||||
Game::logger = new Logger("./MagicEnumTest_ArraysAreSorted.log", true, true);
|
Game::logger = new Logger("./MagicEnumTest_ArraysAreSorted.log", true, true);
|
||||||
|
|
||||||
constexpr auto wmArray = &magic_enum::enum_entries<eWorldMessageType>();
|
constexpr auto wmArray = &magic_enum::enum_entries<eWorldMessageType>();
|
||||||
ASSERT_EARRAY_SORTED(wmArray);
|
AssertEnumArraySorted(wmArray);
|
||||||
|
|
||||||
constexpr auto gmArray = &magic_enum::enum_entries<eGameMessageType>();
|
constexpr auto gmArray = &magic_enum::enum_entries<eGameMessageType>();
|
||||||
ASSERT_EARRAY_SORTED(gmArray);
|
AssertEnumArraySorted(gmArray);
|
||||||
|
|
||||||
delete Game::logger;
|
delete Game::logger;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user