@@ -3,6 +3,7 @@ package logic
33import (
44 "testing"
55
6+ "github.com/morozov/river-raid-ebiten/pkg/domain"
67 "github.com/morozov/river-raid-ebiten/pkg/state"
78)
89
@@ -50,41 +51,39 @@ func TestAddScore_NoBonusLifeWithinSameThreshold(t *testing.T) {
5051 }
5152}
5253
53- func TestUpdateHighScore_ReplacesIfHigher (t * testing.T ) {
54+ func TestRegisterScore_ReplacesIfHigher (t * testing.T ) {
5455 t .Parallel ()
5556
56- var hs [4 ]int
57- hs [0 ] = 1000
58- updateHighScore (& hs , 0 , 2000 )
57+ hs := map [domain.StartingBridge ]int {domain .StartingBridge01 : 1000 }
58+ registerScore (hs , domain .StartingBridge01 , 2000 )
5959
60- if hs [0 ] != 2000 {
61- t .Errorf ("high score = %d, want 2000" , hs [0 ]) //nolint:gosec // G602: fixed-size [4]int, index 0 is always valid
60+ if hs [domain . StartingBridge01 ] != 2000 {
61+ t .Errorf ("high score = %d, want 2000" , hs [domain . StartingBridge01 ])
6262 }
6363}
6464
65- func TestUpdateHighScore_NoChangeIfLower (t * testing.T ) {
65+ func TestRegisterScore_NoChangeIfLower (t * testing.T ) {
6666 t .Parallel ()
6767
68- var hs [4 ]int
69- hs [0 ] = 5000
70- updateHighScore (& hs , 0 , 3000 )
68+ hs := map [domain.StartingBridge ]int {domain .StartingBridge01 : 5000 }
69+ registerScore (hs , domain .StartingBridge01 , 3000 )
7170
72- if hs [0 ] != 5000 {
73- t .Errorf ("high score = %d, want 5000" , hs [0 ]) //nolint:gosec // G602: fixed-size [4]int, index 0 is always valid
71+ if hs [domain . StartingBridge01 ] != 5000 {
72+ t .Errorf ("high score = %d, want 5000" , hs [domain . StartingBridge01 ])
7473 }
7574}
7675
77- func TestUpdateHighScore_UsesCorrectSlot (t * testing.T ) {
76+ func TestRegisterScore_UsesCorrectKey (t * testing.T ) {
7877 t .Parallel ()
7978
80- var hs [ 4 ]int
81- updateHighScore ( & hs , 2 , 9999 )
79+ hs := make ( map [domain. StartingBridge ]int )
80+ registerScore ( hs , domain . StartingBridge20 , 9999 )
8281
83- if hs [2 ] != 9999 {
84- t .Errorf ("hs[2 ] = %d, want 9999" , hs [2 ]) //nolint:gosec // G602: fixed-size [4]int, index 2 is always valid
82+ if hs [domain . StartingBridge20 ] != 9999 {
83+ t .Errorf ("hs[Bridge20 ] = %d, want 9999" , hs [domain . StartingBridge20 ])
8584 }
8685
87- if hs [0 ] != 0 || hs [1 ] != 0 || hs [3 ] != 0 { //nolint:gosec // G602: fixed-size [4]int, indices 0/1/3 are always valid
88- t .Error ("other slots should be unchanged" )
86+ if hs [domain . StartingBridge01 ] != 0 || hs [domain . StartingBridge05 ] != 0 || hs [domain . StartingBridge30 ] != 0 {
87+ t .Error ("other keys should be unchanged" )
8988 }
9089}
0 commit comments