github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/kbfscodec/codec_msgpack_test.go (about) 1 // Copyright 2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package kbfscodec 6 7 import ( 8 "testing" 9 10 "github.com/stretchr/testify/require" 11 ) 12 13 // TestCodecEncodeMap tests that codec.Encode() isn't affected by map 14 // iteration order. 15 func TestCodecEncodeMap(t *testing.T) { 16 m1 := make(map[int]int) 17 m2 := make(map[int]int) 18 for i := 0; i < 10; i++ { 19 m1[i] = 1 20 m2[9-i] = 1 21 } 22 23 codec := NewMsgpack() 24 25 b1, err := codec.Encode(m1) 26 require.NoError(t, err) 27 28 b2, err := codec.Encode(m2) 29 require.NoError(t, err) 30 31 require.Equal(t, b1, b2) 32 }