test: Refactor move tests with subtests and simpler handling

Simplify error handling and improve test structure in move_test.go

- Remove `defer` and `recover` block, streamlining error handling.
- Refactor `t.Log` calls into subtests using `t.Run` for better granularity.
- Organize tests into isolated subtests for clearer execution and reporting.

[board/move_test.go]
- Removed the `defer` and `recover` block for error recovery, simplifying error handling.
- Changed the `t.Log` for each ply into a subtest using `t.Run`.
- Improved test structure by adding isolated subtests for each ply using `t.Run`, providing better granularity for test execution and reporting.
This commit is contained in:
MSWS
2025-03-23 17:10:02 -07:00
parent a7cb54819c
commit 3739104149

View File

@@ -95,17 +95,12 @@ func TestPerfs(t *testing.T) {
}
for ply := 1; ply <= len(test.knownPerfs); ply++ {
t.Log(strconv.Itoa(ply))
defer func() {
err := recover()
if err != nil {
t.Error(err)
t.Run(strconv.Itoa(ply), func(t *testing.T) {
calculated := start.Perft(ply)
if calculated != test.knownPerfs[ply-1] {
t.Fatalf("expected %v nodes, got %v", test.knownPerfs[ply-1], calculated)
}
}()
calculated := start.Perft(ply)
if calculated != test.knownPerfs[ply-1] {
t.Fatalf("expected %v nodes, got %v", test.knownPerfs[ply-1], calculated)
}
})
}
})
}