DEV-765 pipeline refactor (#64)
Refactor rulesets into smaller composable operations In order to mix up the functionality from different rulesets like Solo, Royale, etc. the code in these classes needs to be broken up into small functions that can be composed in a pipeline to make a custom game mode.
This commit is contained in:
parent
5e629e9e93
commit
397d925110
25 changed files with 1475 additions and 222 deletions
|
|
@ -3,6 +3,7 @@ package rules
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
|
@ -247,6 +248,20 @@ func TestEdgeCrossingEating(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestWrap(t *testing.T) {
|
||||
// no wrap
|
||||
assert.Equal(t, int32(0), wrap(0, 0, 0))
|
||||
assert.Equal(t, int32(0), wrap(0, 1, 0))
|
||||
assert.Equal(t, int32(0), wrap(0, 0, 1))
|
||||
assert.Equal(t, int32(1), wrap(1, 0, 1))
|
||||
|
||||
// wrap to min
|
||||
assert.Equal(t, int32(0), wrap(2, 0, 1))
|
||||
|
||||
// wrap to max
|
||||
assert.Equal(t, int32(1), wrap(-1, 0, 1))
|
||||
}
|
||||
|
||||
// Checks that snakes moving out of bounds get wrapped to the other side.
|
||||
var wrappedCaseMoveAndWrap = gameTestCase{
|
||||
"Wrapped Case Move and Wrap",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue