1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-10 18:47:23 -05:00
OpenDiablo2/d2core/d2systems/timescale_test.go

44 lines
767 B
Go
Raw Normal View History

package d2systems
import (
"testing"
"time"
2020-10-12 17:35:11 -04:00
"github.com/gravestench/akara"
)
func TestTimeScaleSystem_Init(t *testing.T) {
2020-10-12 17:35:11 -04:00
cfg := akara.NewWorldConfig()
cfg.With(NewTimeScaleSystem())
2020-10-12 17:35:11 -04:00
world := akara.NewWorld(cfg)
if len(world.Systems) != 1 {
t.Error("system not added to the world")
}
}
func TestTimeScaleSystem_Process(t *testing.T) {
2020-10-12 17:35:11 -04:00
cfg := akara.NewWorldConfig()
timescaleSystem := NewTimeScaleSystem()
cfg.With(timescaleSystem)
timescaleSystem.scale = 0.01
2020-10-12 17:35:11 -04:00
world := akara.NewWorld(cfg)
actual := time.Second
expected := time.Duration(timescaleSystem.scale) * actual
if err := world.Update(actual); err != nil {
timescaleSystem.Error(err.Error())
}
if world.TimeDelta != expected {
t.Error("world time delta not scaled")
}
}