MCPcopy Index your code
hub / github.com/uber-go/nilaway / TestEncoding_Deterministic

Function TestEncoding_Deterministic

util/orderedmap/orderedmap_test.go:161–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func TestEncoding_Deterministic(t *testing.T) {
162 t.Parallel()
163
164 m := orderedmap.New[A, I]()
165 m.Store(A{Number: 1}, &A{})
166 m.Store(A{Number: 2}, &B{})
167
168 // We encode the map 10 times and check that the result is always the same.
169 var previous []byte
170 for i := 0; i < 10; i++ {
171 var buf bytes.Buffer
172 err := gob.NewEncoder(&buf).Encode(m)
173 require.NoError(t, err)
174 require.NotEmpty(t, buf.Bytes())
175 if len(previous) == 0 {
176 previous = buf.Bytes()
177 continue
178 }
179 require.Equal(t, previous, buf.Bytes())
180 }
181}
182
183func TestEncode_Empty(t *testing.T) {
184 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
StoreMethod · 0.80
NotEmptyMethod · 0.80
NoErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected