mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: allow unexported key in Value.MapIndex
Fixes #1748. R=golang-dev, r CC=golang-dev https://golang.org/cl/4444087
This commit is contained in:
parent
8ef56f7e92
commit
86e6a44112
2 changed files with 25 additions and 2 deletions
|
|
@ -726,6 +726,24 @@ func TestDeepEqualComplexStructInequality(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
type UnexpT struct {
|
||||
m map[int]int
|
||||
}
|
||||
|
||||
func TestDeepEqualUnexportedMap(t *testing.T) {
|
||||
// Check that DeepEqual can look at unexported fields.
|
||||
x1 := UnexpT{map[int]int{1: 2}}
|
||||
x2 := UnexpT{map[int]int{1: 2}}
|
||||
if !DeepEqual(&x1, &x2) {
|
||||
t.Error("DeepEqual(x1, x2) = false, want true")
|
||||
}
|
||||
|
||||
y1 := UnexpT{map[int]int{2: 3}}
|
||||
if DeepEqual(&x1, &y1) {
|
||||
t.Error("DeepEqual(x1, y1) = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func check2ndField(x interface{}, offs uintptr, t *testing.T) {
|
||||
s := ValueOf(x)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue