DarkflameServer/tests/dCommonTests/ToUnderlyingTests.cpp
jadebenn 6e3b5acede
chore: Less verbose name for enum underlying type casts (#1494)
* Less verbose name for enum underlying type casts

* Remove redundant call
2024-03-06 23:45:04 -06:00

25 lines
769 B
C++

#include <gtest/gtest.h>
#include "GeneralUtils.h"
#include "eGameMasterLevel.h"
#include "eGameMessageType.h"
#include "eWorldMessageType.h"
#define ASSERT_TYPE_EQ(TYPE, ENUM)\
ASSERT_TRUE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast<ENUM>(0))));
#define ASSERT_TYPE_NE(TYPE, ENUM)\
ASSERT_FALSE(typeid(TYPE) == typeid(GeneralUtils::ToUnderlying(static_cast<ENUM>(0))));
// Verify that the underlying enum types are being cast correctly
TEST(ToUnderlyingTests, VerifyToUnderlying) {
ASSERT_TYPE_EQ(uint8_t, eGameMasterLevel);
ASSERT_TYPE_EQ(uint16_t, eGameMessageType);
ASSERT_TYPE_EQ(uint32_t, eWorldMessageType)
ASSERT_TYPE_NE(void, eGameMasterLevel);
ASSERT_TYPE_NE(void, eGameMessageType);
ASSERT_TYPE_NE(void, eWorldMessageType)
}