diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-21 10:46:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-21 10:46:02 +0900 |
| commit | 642d3b4e1d33afd521f315b9aa99b8993d252902 (patch) | |
| tree | f39e7c191033354db56675d9d3dc4c4be17d7aba /backend/tournament/service_test.go | |
| parent | e8db174d3e464a5764a9f4bfd82172261bd50519 (diff) | |
| download | phperkaigi-2026-albatross-642d3b4e1d33afd521f315b9aa99b8993d252902.tar.gz phperkaigi-2026-albatross-642d3b4e1d33afd521f315b9aa99b8993d252902.tar.zst phperkaigi-2026-albatross-642d3b4e1d33afd521f315b9aa99b8993d252902.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'backend/tournament/service_test.go')
| -rw-r--r-- | backend/tournament/service_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
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) + } + } +} |
