mirror of
https://github.com/danog/liquid.git
synced 2024-12-04 05:37:47 +01:00
24 lines
486 B
Go
24 lines
486 B
Go
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)
|
|
})
|
|
}
|
|
}
|