2021-09-11 21:13:49 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "test_pattern.hpp"
|
|
|
|
|
|
|
|
namespace hex::test {
|
|
|
|
|
|
|
|
class TestPatternEnums : public TestPattern {
|
|
|
|
public:
|
|
|
|
TestPatternEnums() : TestPattern("Enums"){
|
2021-09-25 21:31:37 +00:00
|
|
|
auto testEnum = create<PatternDataEnum>("TestEnum", "testEnum", 0x08, sizeof(u32));
|
2021-09-11 21:13:49 +00:00
|
|
|
testEnum->setEnumValues({
|
2021-09-21 19:29:18 +00:00
|
|
|
{ u128(0x0000), "A" },
|
2021-09-25 21:31:37 +00:00
|
|
|
{ s128(0x0C), "B" },
|
|
|
|
{ u128(0x0D), "C" },
|
|
|
|
{ u128(0x0E), "D" },
|
2021-09-11 21:13:49 +00:00
|
|
|
});
|
2021-09-25 21:31:37 +00:00
|
|
|
testEnum->setEndian(std::endian::big);
|
2021-09-11 21:13:49 +00:00
|
|
|
|
|
|
|
addPattern(testEnum);
|
|
|
|
}
|
|
|
|
~TestPatternEnums() override = default;
|
|
|
|
|
|
|
|
[[nodiscard]]
|
|
|
|
std::string getSourceCode() const override {
|
|
|
|
return R"(
|
|
|
|
enum TestEnum : u32 {
|
|
|
|
A,
|
2021-09-25 21:31:37 +00:00
|
|
|
B = 0x0C,
|
2021-09-11 21:13:49 +00:00
|
|
|
C,
|
|
|
|
D
|
|
|
|
};
|
|
|
|
|
2021-09-25 21:31:37 +00:00
|
|
|
be TestEnum testEnum @ 0x08;
|
|
|
|
|
|
|
|
std::assert(testEnum == TestEnum::C, "Invalid enum value");
|
2021-09-11 21:13:49 +00:00
|
|
|
)";
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|