1
0
mirror of https://github.com/danog/liquid.git synced 2024-12-04 17:07:56 +01:00
liquid/evaluator/accessors_test.go

24 lines
486 B
Go
Raw Normal View History

2017-07-19 00:37:28 +02:00
package evaluator
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
var indexTests = []struct{ array, index, expect interface{} }{
{[]int{1, 2, 3}, 1, 2},
{[]int{1, 2, 3}, 1.0, 2},
{[]int{1, 2, 3}, 1.1, nil},
}
func TestIndex(t *testing.T) {
for i, test := range indexTests {
t.Run(fmt.Sprintf("%02d", i+1), func(t *testing.T) {
actual := Index(test.array, test.index)
require.Equalf(t, test.expect, actual, "%v[%v]", test.array, test.index)
})
}
}