MCPcopy
hub / github.com/vmihailenco/msgpack / TestSetSortMapKeys

Function TestSetSortMapKeys

msgpack_test.go:383–412  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

381}
382
383func TestSetSortMapKeys(t *testing.T) {
384 in := map[string]interface{}{
385 "a": "a",
386 "b": "b",
387 "c": "c",
388 "d": "d",
389 }
390
391 var buf bytes.Buffer
392 enc := msgpack.NewEncoder(&buf)
393 enc.SetSortMapKeys(true)
394 dec := msgpack.NewDecoder(&buf)
395
396 err := enc.Encode(in)
397 require.Nil(t, err)
398
399 wanted := make([]byte, buf.Len())
400 copy(wanted, buf.Bytes())
401 buf.Reset()
402
403 for i := 0; i < 100; i++ {
404 err := enc.Encode(in)
405 require.Nil(t, err)
406 require.Equal(t, wanted, buf.Bytes())
407
408 out, err := dec.DecodeMap()
409 require.Nil(t, err)
410 require.Equal(t, in, out)
411 }
412}
413
414func TestSetOmitEmpty(t *testing.T) {
415 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 4

SetSortMapKeysMethod · 0.95
EncodeMethod · 0.95
DecodeMapMethod · 0.95
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…