From 642d3b4e1d33afd521f315b9aa99b8993d252902 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 10:46:02 +0900 Subject: refactor(admin): separate business logic into game and tournament services Move transaction handling, rejudge workflow, tournament bracket creation, and data repair logic from admin handler into game.Service and tournament.Service, mirroring the earlier api package separation. Co-Authored-By: Claude Opus 4.6 --- backend/tournament/service_test.go | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'backend/tournament/service_test.go') diff --git a/backend/tournament/service_test.go b/backend/tournament/service_test.go index d1ca78c..c43fb4e 100644 --- a/backend/tournament/service_test.go +++ b/backend/tournament/service_test.go @@ -95,3 +95,44 @@ func TestFindSeedByUserID(t *testing.T) { t.Errorf("expected seed 0 for unknown user, got %d", got) } } + +func TestNextPowerOf2(t *testing.T) { + tests := []struct { + input int + expected int + }{ + {2, 2}, + {3, 4}, + {4, 4}, + {5, 8}, + {6, 8}, + {7, 8}, + {8, 8}, + {9, 16}, + } + for _, tt := range tests { + got := nextPowerOf2(tt.input) + if got != tt.expected { + t.Errorf("nextPowerOf2(%d) = %d, want %d", tt.input, got, tt.expected) + } + } +} + +func TestLog2Int(t *testing.T) { + tests := []struct { + input int + expected int + }{ + {1, 0}, + {2, 1}, + {4, 2}, + {8, 3}, + {16, 4}, + } + for _, tt := range tests { + got := log2Int(tt.input) + if got != tt.expected { + t.Errorf("log2Int(%d) = %d, want %d", tt.input, got, tt.expected) + } + } +} -- cgit v1.3.1