1// +build go1.15
2// remove these tests temporarily until https://github.com/golang/go/issues/38105 and
3// https://github.com/golang/go/issues/38940 is fixed
4
5package test
6
7import (
8	"encoding"
9	"strings"
10)
11
12func init() {
13	testCases = append(testCases,
14		(*map[stringKeyType]string)(nil),
15		(*map[structKeyType]string)(nil),
16	)
17}
18
19type stringKeyType string
20
21func (k stringKeyType) MarshalText() ([]byte, error) {
22	return []byte("MANUAL__" + k), nil
23}
24
25func (k *stringKeyType) UnmarshalText(text []byte) error {
26	*k = stringKeyType(strings.TrimPrefix(string(text), "MANUAL__"))
27	return nil
28}
29
30var _ encoding.TextMarshaler = stringKeyType("")
31var _ encoding.TextUnmarshaler = new(stringKeyType)
32
33type structKeyType struct {
34	X string
35}
36
37func (k structKeyType) MarshalText() ([]byte, error) {
38	return []byte("MANUAL__" + k.X), nil
39}
40
41func (k *structKeyType) UnmarshalText(text []byte) error {
42	k.X = strings.TrimPrefix(string(text), "MANUAL__")
43	return nil
44}
45
46var _ encoding.TextMarshaler = structKeyType{}
47var _ encoding.TextUnmarshaler = &structKeyType{}
48