Skip to content

Commit

Permalink
Add entity builder test
Browse files Browse the repository at this point in the history
  • Loading branch information
GsLogiMaker committed Jan 8, 2025
1 parent 0156b1b commit 3a0ad59
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions unittests/test_entities.gd
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ func test_builder():
.set_name("Built") \
.add_entity(Foo) \
.add_pair(Foo, Stringy) \
.add_pair(Stringy, Foo) \
.build()

assert_eq(e.get_name(), "Built", "Expected entity to be named 'Built'")

var query:GFQuery = GFQueryBuilder.new_in_world(world) \
.with(Foo) \
.with(world.pair(Foo, Stringy)) \
.with(world.pair(Stringy, Foo)) \
.build()

var i:= 0
Expand All @@ -108,16 +110,18 @@ func test_builder():
#region Classes

class Foo extends GFComponent:
func _build(b_: GFComponentBuilder) -> void:
b_.add_member("value", TYPE_FLOAT)
func _build(b_: GFComponentBuilder) -> void: b_ \
.set_name("Foo") \
.add_member("value", TYPE_FLOAT)
var value:float:
get: return getm(&"value")
set(v): setm(&"value", v)

class Stringy extends GFComponent:
func _build(b_: GFComponentBuilder) -> void:
b_.add_member("a", TYPE_STRING)
b_.add_member("b", TYPE_STRING)
func _build(b_: GFComponentBuilder) -> void: b_ \
.set_name("Stringy") \
.add_member("a", TYPE_STRING) \
.add_member("b", TYPE_STRING)
var a:String:
get: return getm(&"a")
set(v): setm(&"a", v)
Expand All @@ -126,15 +130,17 @@ class Stringy extends GFComponent:
set(v): setm(&"b", v)

class Unadded extends GFComponent:
func _build(b_: GFComponentBuilder) -> void:
b_.add_member("value", TYPE_INT)
func _build(b_: GFComponentBuilder) -> void: b_ \
.set_name("Unadded") \
.add_member("value", TYPE_INT)
var value:int:
get: return getm(&"value")
set(v): setm(&"value", v)

class Unregistered extends GFComponent:
func _build(b_: GFComponentBuilder) -> void:
b_.add_member("value", TYPE_INT)
func _build(b_: GFComponentBuilder) -> void: b_ \
.set_name("Unregistered") \
.add_member("value", TYPE_INT)
var value:int:
get: return getm(&"value")
set(v): setm(&"value", v)
Expand Down

0 comments on commit 3a0ad59

Please sign in to comment.