Skip to content

Commit 86eafe5

Browse files
mgi388makspll
andauthored
feat: add test for construct using unit struct (#328)
Co-authored-by: Maksymilian Mozolewski <[email protected]>
1 parent 8b588b4 commit 86eafe5

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
local type = world.get_type_by_name("UnitStruct")
2+
local constructed = construct(type, {})
3+
4+
assert(constructed ~= nil, "Value was not constructed")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let type = world.get_type_by_name.call("UnitStruct");
2+
let constructed = construct.call(type, #{});

crates/testing_crates/test_utils/src/test_data.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ impl TestResourceWithVariousFields {
145145
}
146146
}
147147

148+
#[derive(Component, Reflect, PartialEq, Eq, Debug, Default)]
149+
#[reflect(Component, Default)]
150+
pub struct UnitStruct;
151+
152+
impl UnitStruct {
153+
pub fn init() -> Self {
154+
Self
155+
}
156+
}
157+
148158
#[derive(Component, Reflect, PartialEq, Eq, Debug, Default)]
149159
#[reflect(Component, Default)]
150160
pub struct SimpleStruct {
@@ -262,14 +272,15 @@ impl_test_component_ids!(
262272
CompWithDefault => 2,
263273
CompWithDefaultAndComponentData => 3,
264274
CompWithFromWorldAndComponentData => 4,
265-
SimpleStruct => 5,
266-
SimpleTupleStruct => 6,
267-
SimpleEnum => 7,
275+
UnitStruct => 5,
276+
SimpleStruct => 6,
277+
SimpleTupleStruct => 7,
278+
SimpleEnum => 8,
268279
],
269280
[
270-
TestResource => 8,
271-
ResourceWithDefault => 9,
272-
TestResourceWithVariousFields => 10,
281+
TestResource => 9,
282+
ResourceWithDefault => 10,
283+
TestResourceWithVariousFields => 11,
273284
]
274285
);
275286

0 commit comments

Comments
 (0)