Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Add unit test for drop candy logic #81

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions game/gamemap/dropcandy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package gamemap

import (
"testing"

"candy/game/square"

"github.com/stretchr/testify/assert"
)

func TestDropCandyChecker_CanDropCandy(t *testing.T) {
testCases := []struct {
name string
gameMap *Map
playerX int
playerY int
expectedCanDropCandy bool
}{
{
name: "map empty",
gameMap: &Map{
batch: nil,
maxRow: 4,
maxCol: 4,
grid: &[][]square.Square{
{nil, nil, nil, nil},
{nil, nil, nil, nil},
{nil, nil, nil, nil},
{nil, nil, nil, nil},
},
},
playerX: 1,
playerY: 2,
expectedCanDropCandy: true,
},
}

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
dropCandyChecker := NewDropCandyChecker(testCase.gameMap)
gotCanDropCandyCheck := dropCandyChecker.CanDropCandy(
testCase.playerX,
testCase.playerY,
1,
1)
assert.Equal(t, testCase.expectedCanDropCandy, gotCanDropCandyCheck)
})
}
}