mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: make map test independent of map iteration order.
This should fix the 386 builds. R=golang-dev, adg CC=golang-dev https://golang.org/cl/5298042
This commit is contained in:
parent
fdc6376c00
commit
9049abbd2d
1 changed files with 10 additions and 9 deletions
|
|
@ -877,19 +877,20 @@ func TestMap(t *testing.T) {
|
||||||
t.Errorf("Len = %d, want %d", n, len(m))
|
t.Errorf("Len = %d, want %d", n, len(m))
|
||||||
}
|
}
|
||||||
keys := mv.MapKeys()
|
keys := mv.MapKeys()
|
||||||
i := 0
|
|
||||||
newmap := MakeMap(mv.Type())
|
newmap := MakeMap(mv.Type())
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
// Check that returned Keys match keys in range.
|
// Check that returned Keys match keys in range.
|
||||||
// These aren't required to be in the same order,
|
// These aren't required to be in the same order.
|
||||||
// but they are in this implementation, which makes
|
seen := false
|
||||||
// the test easier.
|
for _, kv := range keys {
|
||||||
if i >= len(keys) {
|
if kv.String() == k {
|
||||||
t.Errorf("Missing key #%d %q", i, k)
|
seen = true
|
||||||
} else if kv := keys[i]; kv.String() != k {
|
break
|
||||||
t.Errorf("Keys[%q] = %q, want %q", i, kv.String(), k)
|
}
|
||||||
|
}
|
||||||
|
if !seen {
|
||||||
|
t.Errorf("Missing key %q", k)
|
||||||
}
|
}
|
||||||
i++
|
|
||||||
|
|
||||||
// Check that value lookup is correct.
|
// Check that value lookup is correct.
|
||||||
vv := mv.MapIndex(ValueOf(k))
|
vv := mv.MapIndex(ValueOf(k))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue