test for math2d and wave

This commit is contained in:
2026-06-27 23:11:18 -07:00
parent e7806dcd66
commit 6bdb096e1b
2 changed files with 121 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
package game
import "core:testing"
@(test)
test_start_wave_enters_combat :: proc(t: ^testing.T) {
world := World {
phase = .Combat,
}
world.wave.current_wave = 0
start_wave(&world)
testing.expect(t, world.phase == .Combat)
testing.expect(t, world.wave.current_wave == 0)
}
@(test)
test_start_wave_from_build :: proc(t: ^testing.T) {
world := World {
phase = .Build,
}
world.wave.current_wave = 0
start_wave(&world)
testing.expect(t, world.phase == .Combat)
testing.expect(t, world.wave.current_wave == 1)
testing.expect(t, world.wave.spawner.spawn_timer == 0)
testing.expect(t, world.wave.spawner.spawn_interval == 0.55)
testing.expect(t, world.wave.spawner.recipe_index == 0)
}
@(test)
test_clear_wave_not_cleared :: proc(t: ^testing.T) {
world := World{}
world.wave.spawner.recipe = make([dynamic]Wave_Entry, context.allocator)
append(&world.wave.spawner.recipe, Wave_Entry{})
defer delete(world.wave.spawner.recipe); world.wave.spawner.recipe_index = 0
world.wave.spawner.entry_remaining = 0
result := clear_wave(&world)
testing.expect(t, result == false)
}
@(test)
test_clear_wave_cleared :: proc(t: ^testing.T) {
world := World{}
world.wave.spawner.recipe = make([dynamic]Wave_Entry, context.allocator)
append(&world.wave.spawner.recipe, Wave_Entry{})
defer delete(world.wave.spawner.recipe); world.wave.spawner.recipe_index = 1
world.wave.spawner.entry_remaining = 0
result := clear_wave(&world)
testing.expect(t, result == true)
}