mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-11-27 05:16:18 +08:00
39 lines
918 B
C++
39 lines
918 B
C++
#include <cassert>
|
|
// Redefine the range of the enums
|
|
#define RFL_ENUM_RANGE_MIN -128
|
|
#define RFL_ENUM_RANGE_MAX 128
|
|
#include <rfl.hpp>
|
|
|
|
#include "write_and_read.hpp"
|
|
|
|
namespace test_enum_range {
|
|
|
|
enum class InnerColor { none = -128, red = -50, green = 0, blue = 128 };
|
|
enum class LineColor { yellow = 200, purple = 300, orange = 400 };
|
|
|
|
struct Circle {
|
|
float radius;
|
|
InnerColor inner_color;
|
|
LineColor line_color;
|
|
};
|
|
|
|
} // namespace test_enum_range
|
|
|
|
// Define the range of the LineColor enum
|
|
template <>
|
|
struct rfl::config::enum_range<test_enum_range::LineColor> {
|
|
static constexpr int min = 200;
|
|
static constexpr int max = 400;
|
|
};
|
|
|
|
namespace test_enum_range {
|
|
|
|
TEST(generic, test_enum_range) {
|
|
auto circle = Circle{.radius = 2.0,
|
|
.inner_color = InnerColor::none,
|
|
.line_color = LineColor::yellow};
|
|
|
|
write_and_read(circle);
|
|
}
|
|
|
|
} // namespace test_enum_range
|