Skip to content

Commit

Permalink
#1466 Add test that ensures empty enum reflection works
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Dec 18, 2024
1 parent 545b5a8 commit d911c70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion test/cpp/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@
"mixed_auto_manual_constants",
"enum_class_mixed_auto_manual_constants",
"enum_child_count",
"multi_world_constant_ids"
"multi_world_constant_ids",
"empty_enum"
]
}, {
"id": "Union",
Expand Down
10 changes: 10 additions & 0 deletions test/cpp/src/Enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ enum class EnumClassWithLargeConstant {
X, Y, Z = 1000
};

enum EmptyEnum { };

/* Optional, but improves compile time */
FLECS_ENUM_LAST(StandardEnum, Blue)
FLECS_ENUM_LAST(SparseEnum, Grey)
Expand Down Expand Up @@ -1205,3 +1207,11 @@ void Enum_multi_world_constant_ids(void) {
test_assert(green_a == world_a.to_entity(StandardEnum::Green));
test_assert(blue_a == world_a.to_entity(StandardEnum::Blue));
}

void Enum_empty_enum(void) {
flecs::world ecs;

auto enum_type = flecs::enum_type<EmptyEnum>(ecs);

test_int(enum_type.index_by_value(0), -1);
}
7 changes: 6 additions & 1 deletion test/cpp/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ void Enum_mixed_auto_manual_constants(void);
void Enum_enum_class_mixed_auto_manual_constants(void);
void Enum_enum_child_count(void);
void Enum_multi_world_constant_ids(void);
void Enum_empty_enum(void);

// Testsuite 'Union'
void Union_add_case(void);
Expand Down Expand Up @@ -2980,6 +2981,10 @@ bake_test_case Enum_testcases[] = {
{
"multi_world_constant_ids",
Enum_multi_world_constant_ids
},
{
"empty_enum",
Enum_empty_enum
}
};

Expand Down Expand Up @@ -6926,7 +6931,7 @@ static bake_test_suite suites[] = {
"Enum",
NULL,
NULL,
40,
41,
Enum_testcases
},
{
Expand Down

0 comments on commit d911c70

Please sign in to comment.