MCPcopy Create free account
hub / github.com/WICG/webpackage / TestEncodeMapWithDuplicatedKeys

Function TestEncodeMapWithDuplicatedKeys

go/internal/cbor/encoder_test.go:125–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

123}
124
125func TestEncodeMapWithDuplicatedKeys(t *testing.T) {
126 entries := []*MapEntryEncoder{
127 GenerateMapEntry(func(keyE *Encoder, valueE *Encoder) {
128 keyE.EncodeTextString("key")
129 valueE.EncodeTextString("value1")
130 }),
131 GenerateMapEntry(func(keyE *Encoder, valueE *Encoder) {
132 keyE.EncodeTextString("key")
133 valueE.EncodeTextString("value2")
134 }),
135 }
136
137 var b bytes.Buffer
138 e := NewEncoder(&b)
139 if err := e.EncodeMap(entries); err == nil {
140 t.Error("Expected an error for duplicated map key")
141 }
142}
143
144func TestMapEncoder(t *testing.T) {
145 entries := []*MapEntryEncoder{

Callers

nothing calls this directly

Calls 4

EncodeMapMethod · 0.95
GenerateMapEntryFunction · 0.85
NewEncoderFunction · 0.85
EncodeTextStringMethod · 0.80

Tested by

no test coverage detected