Skip to content

Commit

Permalink
test(cardinal): test to maintain interface component. (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrofolium authored Nov 2, 2023
1 parent a9a6560 commit 4807cf1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cardinal/ecs/component/metadata/component_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"gotest.tools/v3/assert"

"pkg.world.dev/world-engine/cardinal/ecs/entity"
"pkg.world.dev/world-engine/cardinal/ecs/filter"

Expand All @@ -27,6 +28,16 @@ type ComponentDataB struct {

func (ComponentDataB) Name() string { return "b" }

func getNameOfComponent(c metadata.Component) string {
return c.Name()
}

func TestComponentInterfaceSignature(t *testing.T) {
// The purpose of this test is to maintain api compatibility.
// It is to prevent the interface signature of metadata.Component from changing.
assert.Equal(t, getNameOfComponent(&ComponentDataA{}), "a")
}

func TestComponents(t *testing.T) {
world := ecs.NewTestWorld(t)
ecs.MustRegisterComponent[ComponentDataA](world)
Expand Down

0 comments on commit 4807cf1

Please sign in to comment.