Fixed memory issues with new Enum ToString handling.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
9244249a64
commit
f89fb303b5
|
@ -63,7 +63,7 @@
|
||||||
switch (value) { MACRO_UTILS_FOR_EACH(ENUM_CASE, name, values) } \
|
switch (value) { MACRO_UTILS_FOR_EACH(ENUM_CASE, name, values) } \
|
||||||
auto v = static_cast<int>(value); \
|
auto v = static_cast<int>(value); \
|
||||||
auto size = (int)((ceil(log10(v)) + 1) * sizeof(char)); \
|
auto size = (int)((ceil(log10(v)) + 1) * sizeof(char)); \
|
||||||
char* snum = new char[size]; \
|
char* snum = new char[size + 1]; \
|
||||||
sprintf(snum, "%d", v); \
|
sprintf(snum, "%d", v); \
|
||||||
return snum; \
|
return snum; \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -56,7 +56,9 @@ TEST_CASE("Enum To String", "[Utilities]") {
|
||||||
CHECK(strcmp(TestEnumHelper::ToString(TestEnum::Val1), "Val1") == 0);
|
CHECK(strcmp(TestEnumHelper::ToString(TestEnum::Val1), "Val1") == 0);
|
||||||
CHECK(strcmp(TestEnumHelper::ToString(TestEnum::Val2), "Val2") == 0);
|
CHECK(strcmp(TestEnumHelper::ToString(TestEnum::Val2), "Val2") == 0);
|
||||||
CHECK(strcmp(TestEnumHelper::ToString(TestEnum::Val3), "Val3") == 0);
|
CHECK(strcmp(TestEnumHelper::ToString(TestEnum::Val3), "Val3") == 0);
|
||||||
CHECK(strcmp(TestEnumHelper::ToString((TestEnum)100), "100") == 0);
|
auto s = TestEnumHelper::ToString((TestEnum)100);
|
||||||
|
CHECK(strcmp(s, "100") == 0);
|
||||||
|
delete[] s;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Enum Get Values", "[Utilities]") {
|
TEST_CASE("Enum Get Values", "[Utilities]") {
|
||||||
|
|
Loading…
Reference in New Issue