// Code generated by go generate. DO NOT EDIT.

package opt

import (
	"encoding/json"
	"testing"

	"github.com/algolia/algoliasearch-client-go/v3/algolia/opt"
	"github.com/stretchr/testify/require"
)

func TestLimit(t *testing.T) {
	for _, c := range []struct {
		opts     []interface{}
		expected *opt.LimitOption
	}{
		{
			opts:     []interface{}{nil},
			expected: opt.Limit(10),
		},
		{
			opts:     []interface{}{opt.Limit(0)},
			expected: opt.Limit(0),
		},
		{
			opts:     []interface{}{opt.Limit(1)},
			expected: opt.Limit(1),
		},
		{
			opts:     []interface{}{opt.Limit(-42)},
			expected: opt.Limit(-42),
		},
	} {
		var (
			in  = ExtractLimit(c.opts...)
			out opt.LimitOption
		)
		data, err := json.Marshal(&in)
		require.NoError(t, err)
		err = json.Unmarshal(data, &out)
		require.NoError(t, err)
		require.Equal(t, *c.expected, out)
	}
}
