Skip to content

Commit 37e3172

Browse files
committed
encoding/mvt: remove use of crypto/md5 to compare marshalling in tests
1 parent 458ea58 commit 37e3172

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

encoding/mvt/marshal_test.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package mvt
22

33
import (
4-
"crypto/md5"
5-
"encoding/hex"
4+
"bytes"
65
"encoding/json"
76
"fmt"
87
"io/ioutil"
@@ -542,17 +541,13 @@ func TestMarshal_ID(t *testing.T) {
542541

543542
func TestStableMarshalling(t *testing.T) {
544543
layers := NewLayers(loadGeoJSON(t, maptile.New(17896, 24449, 16)))
545-
values := make(map[string]bool)
546544

545+
firstData, _ := Marshal(layers)
547546
for i := 0; i < 100; i++ {
548-
marshal, _ := Marshal(layers)
549-
checksum := md5.Sum(marshal)
550-
sum := hex.EncodeToString(checksum[:])
551-
values[sum] = true
552-
}
553-
554-
if len(values) != 1 {
555-
t.Errorf("multiple values (%d) for marshalled bytes", len(values))
547+
data, _ := Marshal(layers)
548+
if !bytes.Equal(data, firstData) {
549+
t.Errorf("a marshal had different bytes")
550+
}
556551
}
557552
}
558553

0 commit comments

Comments
 (0)