Skip to content

Commit

Permalink
Changed tese to reconstruct map. #161
Browse files Browse the repository at this point in the history
  • Loading branch information
gdey committed Feb 13, 2018
1 parent b80d958 commit be25743
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions atlas/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,38 +291,29 @@ func TestEncode(t *testing.T) {
}
}

if len(tileLayer.Keys) != len(expectedLayer.Keys) {
if *tileLayer.Extent != *expectedLayer.Extent {
t.Errorf("[%v] expected %v got %v", i, *tileLayer.Extent, *expectedLayer.Extent)
continue
}

if len(expectedLayer.Keys) != len(tileLayer.Keys) {
t.Errorf("[%v] key len expected %v got %v", i, len(expectedLayer.Keys), len(tileLayer.Keys))
continue

}
{
var kmap = make(map[string]struct{})
for _, k := range tileLayer.Keys {
kmap[k] = struct{}{}
}
for _, k := range expectedLayer.Keys {
if _, ok := kmap[k]; !ok {
t.Errorf("[%v] missing key expected %v got nil", i, k)

}
}
var gotmap = make(map[string]interface{})
var expmap = make(map[string]interface{})
for i, k := range tileLayer.Keys {
gotmap[k] = tileLayer.Values[i]
}

if *tileLayer.Extent != *expectedLayer.Extent {
t.Errorf("[%v] expected %v got %v", i, *tileLayer.Extent, *expectedLayer.Extent)
continue
for i, k := range expectedLayer.Keys {
expmap[k] = expectedLayer.Values[i]
}

for l, tileLayerValues := range tileLayer.Values {
expectedTileLayerValues := expectedLayer.Values[l]

// TODO (arolek): add additional value checks
if *tileLayerValues.StringValue != *expectedTileLayerValues.StringValue {
t.Errorf("[%v] expected %v got %v", i, *tileLayerValues.StringValue, *expectedTileLayerValues.StringValue)
continue
}
if !reflect.DeepEqual(expmap, gotmap) {
t.Errorf("[%v] constructed map expected %v got %v", i, expmap, gotmap)
}

}
}
}

0 comments on commit be25743

Please sign in to comment.