Skip to content

Commit

Permalink
Merge pull request #118 from paulmach/rm-md5
Browse files Browse the repository at this point in the history
encoding/mvt: remove use of crypto/md5 to compare marshalling in tests
  • Loading branch information
paulmach authored Jan 6, 2023
2 parents ace85f4 + 37e3172 commit 07e2162
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions encoding/mvt/marshal_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package mvt

import (
"crypto/md5"
"encoding/hex"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -542,17 +541,13 @@ func TestMarshal_ID(t *testing.T) {

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

firstData, _ := Marshal(layers)
for i := 0; i < 100; i++ {
marshal, _ := Marshal(layers)
checksum := md5.Sum(marshal)
sum := hex.EncodeToString(checksum[:])
values[sum] = true
}

if len(values) != 1 {
t.Errorf("multiple values (%d) for marshalled bytes", len(values))
data, _ := Marshal(layers)
if !bytes.Equal(data, firstData) {
t.Errorf("a marshal had different bytes")
}
}
}

Expand Down

0 comments on commit 07e2162

Please sign in to comment.