feat(collections): IndexedMap (#14397)

Co-authored-by: testinginprod <testinginprod@somewhere.idk>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
This commit is contained in:
testinginprod
2023-01-27 12:49:27 +00:00
committed by GitHub
co-authored by testinginprod Marko Likhita Polavarapu
parent ed17f2d437
commit 519630ea64
21 changed files with 892 additions and 52 deletions
+48
View File
@@ -0,0 +1,48 @@
package colltest
import "testing"
type animal interface {
name() string
}
type dog struct {
Name string `json:"name"`
BarksLoudly bool `json:"barks_loudly"`
}
type cat struct {
Name string `json:"name"`
Scratches bool `json:"scratches"`
}
func (d *cat) name() string { return d.Name }
func (d dog) name() string { return d.Name }
func TestMockValueCodec(t *testing.T) {
t.Run("primitive type", func(t *testing.T) {
x := MockValueCodec[string]()
TestValueCodec(t, x, "hello")
})
t.Run("struct type", func(t *testing.T) {
x := MockValueCodec[dog]()
TestValueCodec(t, x, dog{
Name: "kernel",
BarksLoudly: true,
})
})
t.Run("interface type", func(t *testing.T) {
x := MockValueCodec[animal]()
TestValueCodec[animal](t, x, dog{
Name: "kernel",
BarksLoudly: true,
})
TestValueCodec[animal](t, x, &cat{
Name: "echo",
Scratches: true,
})
})
}