Skip to content

Commit

Permalink
feat: add test for construct using unit struct
Browse files Browse the repository at this point in the history
  • Loading branch information
mgi388 committed Feb 26, 2025
1 parent 7a251c0 commit 2f5d05d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local type = world.get_type_by_name("UnitStruct")
local constructed = construct(type, {})

assert(constructed ~= nil, "Value was not constructed")
23 changes: 17 additions & 6 deletions crates/testing_crates/test_utils/src/test_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ impl TestResourceWithVariousFields {
}
}

#[derive(Component, Reflect, PartialEq, Eq, Debug, Default)]
#[reflect(Component, Default)]
pub struct UnitStruct;

impl UnitStruct {
pub fn init() -> Self {
Self
}
}

#[derive(Component, Reflect, PartialEq, Eq, Debug, Default)]
#[reflect(Component, Default)]
pub struct SimpleStruct {
Expand Down Expand Up @@ -256,14 +266,15 @@ impl_test_component_ids!(
CompWithDefault => 2,
CompWithDefaultAndComponentData => 3,
CompWithFromWorldAndComponentData => 4,
SimpleStruct => 5,
SimpleTupleStruct => 6,
SimpleEnum => 7,
UnitStruct => 5,
SimpleStruct => 6,
SimpleTupleStruct => 7,
SimpleEnum => 8,
],
[
TestResource => 8,
ResourceWithDefault => 9,
TestResourceWithVariousFields => 10,
TestResource => 9,
ResourceWithDefault => 10,
TestResourceWithVariousFields => 11,
]
);

Expand Down

0 comments on commit 2f5d05d

Please sign in to comment.