neo-go/pkg/smartcontract/binding/override_test.go
Evgeniy Stratonikov da03d895de cli/smartcontract: generate bindings to an existing contract
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-23 15:40:06 +03:00

32 lines
1.1 KiB
Go

package binding
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestNewOverrideFromString(t *testing.T) {
testCases := []struct {
expected Override
value string
}{
{Override{"import.com/pkg", "pkg.Type"}, "import.com/pkg.Type"},
{Override{"", "map[int]int"}, "map[int]int"},
{Override{"", "[]int"}, "[]int"},
{Override{"", "map[int][]int"}, "map[int][]int"},
{Override{"import.com/pkg", "map[int]pkg.Type"}, "map[int]import.com/pkg.Type"},
{Override{"import.com/pkg", "[]pkg.Type"}, "[]import.com/pkg.Type"},
{Override{"import.com/pkg", "map[int]*pkg.Type"}, "map[int]*import.com/pkg.Type"},
{Override{"import.com/pkg", "[]*pkg.Type"}, "[]*import.com/pkg.Type"},
{Override{"import.com/pkg", "[][]*pkg.Type"}, "[][]*import.com/pkg.Type"},
{Override{"import.com/pkg", "map[string][]pkg.Type"}, "map[string][]import.com/pkg.Type"}}
for _, tc := range testCases {
require.Equal(t, tc.expected, NewOverrideFromString(tc.value))
s, err := tc.expected.MarshalYAML()
require.NoError(t, err)
require.Equal(t, tc.value, s)
}
}