mirror of
https://github.com/MSWS/Chess.git
synced 2025-12-06 05:32:37 -08:00
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:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user