From 5b78c3dbd44f3887d281c97921fdc909f8ccbcbe Mon Sep 17 00:00:00 2001 From: CPunch Date: Sat, 25 Nov 2023 23:36:23 -0600 Subject: [PATCH] added entity_test.go --- internal/entity/entity_test.go | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 internal/entity/entity_test.go diff --git a/internal/entity/entity_test.go b/internal/entity/entity_test.go new file mode 100644 index 0000000..b043b11 --- /dev/null +++ b/internal/entity/entity_test.go @@ -0,0 +1,40 @@ +package entity_test + +import ( + "testing" + + "github.com/CPunch/gopenfusion/internal/entity" +) + +func TestChunkSliceDifference(t *testing.T) { + chunks := []*entity.Chunk{ + entity.NewChunk(entity.MakeChunkPosition(0, 0)), + entity.NewChunk(entity.MakeChunkPosition(0, 1)), + entity.NewChunk(entity.MakeChunkPosition(1, 0)), + entity.NewChunk(entity.MakeChunkPosition(1, 1)), + } + + c1 := []*entity.Chunk{ + chunks[0], + chunks[1], + chunks[2], + chunks[3], + } + + c2 := []*entity.Chunk{ + chunks[0], + chunks[1], + chunks[2], + } + + diff := entity.ChunkSliceDifference(c1, c2) + if len(diff) != 1 { + t.Logf("%+v", diff) + t.Error("expected 1 chunk in difference") + } + + if diff[0] != chunks[3] { + t.Logf("%+v", diff) + t.Error("wrong difference") + } +}