mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-24 00:00:18 +00:00
added entity_test.go
This commit is contained in:
parent
d31723e245
commit
5b78c3dbd4
40
internal/entity/entity_test.go
Normal file
40
internal/entity/entity_test.go
Normal file
@ -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")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user