40 lines
1.4 KiB
C++
40 lines
1.4 KiB
C++
|
#ifdef TESTS_BUILD
|
||
|
#include <cstring>
|
||
|
#include "../extern/catch.hpp"
|
||
|
#include "../src/Core/Enum.hpp"
|
||
|
|
||
|
ENUM(TestEnum, uint8_t, Val1, Val2, Val3)
|
||
|
|
||
|
TEST_CASE("Parse Enum case sensitive", "[Utilities]") {
|
||
|
CHECK(TestEnumHelper::Parse("Val1") == TestEnum::Val1);
|
||
|
CHECK(TestEnumHelper::Parse("Val2") == TestEnum::Val2);
|
||
|
CHECK(TestEnumHelper::Parse("Val3") == TestEnum::Val3);
|
||
|
CHECK_THROWS(TestEnumHelper::Parse("Val4"));
|
||
|
CHECK_THROWS(TestEnumHelper::Parse("val1"));
|
||
|
}
|
||
|
|
||
|
TEST_CASE("Parse Enum case insensitive", "[Utilities]") {
|
||
|
CHECK(TestEnumHelper::Parse("Val1", true) == TestEnum::Val1);
|
||
|
CHECK(TestEnumHelper::Parse("Val2", true) == TestEnum::Val2);
|
||
|
CHECK(TestEnumHelper::Parse("Val3", true) == TestEnum::Val3);
|
||
|
CHECK(TestEnumHelper::Parse("val1", true) == TestEnum::Val1);
|
||
|
CHECK(TestEnumHelper::Parse("vAL2", true) == TestEnum::Val2);
|
||
|
CHECK(TestEnumHelper::Parse("VaL3", true) == TestEnum::Val3);
|
||
|
CHECK_THROWS(TestEnumHelper::Parse("Val4", true));
|
||
|
}
|
||
|
|
||
|
TEST_CASE("Enum To String", "[Utilities]") {
|
||
|
CHECK(TestEnumHelper::ToString(TestEnum::Val1) == "Val1");
|
||
|
CHECK(TestEnumHelper::ToString(TestEnum::Val2) == "Val2");
|
||
|
CHECK(TestEnumHelper::ToString(TestEnum::Val3) == "Val3");
|
||
|
}
|
||
|
|
||
|
TEST_CASE("Enum Get Values", "[Utilities]") {
|
||
|
auto vec = TestEnumHelper::GetValues();
|
||
|
REQUIRE(vec.size() == 3);
|
||
|
CHECK(vec[0] == TestEnum::Val1);
|
||
|
CHECK(vec[1] == TestEnum::Val2);
|
||
|
CHECK(vec[2] == TestEnum::Val3);
|
||
|
}
|
||
|
|
||
|
#endif
|