...
1 package option_test
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7 "github.com/lestrrat-go/option"
8 )
9
10 type identFoo struct{}
11 type identBar struct{}
12
13 func TestOption(t *testing.T) {
14 options := []option.Interface{
15 option.New(identFoo{}, "foo"),
16 option.New(identBar{}, 1),
17 }
18
19 expected := []struct {
20 ident interface{}
21 value interface{}
22 }{
23 {
24 ident: identFoo{},
25 value: "foo",
26 },
27 {
28 ident: identBar{},
29 value: 1,
30 },
31 }
32
33 for i := 0; i < len(options); i++ {
34 if !assert.Equal(t, expected[i].ident, options[i].Ident(), `identities should match`) {
35 return
36 }
37 if !assert.Equal(t, expected[i].value, options[i].Value(), `values should match`) {
38 return
39 }
40 }
41 }
42
View as plain text