LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package gob | 5 package gob |
6 | 6 |
7 import ( | 7 import ( |
8 "reflect" | 8 "reflect" |
9 "testing" | 9 "testing" |
10 ) | 10 ) |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 name string | 170 name string |
171 }{ | 171 }{ |
172 {&N1{}, "*gob.N1"}, | 172 {&N1{}, "*gob.N1"}, |
173 {N2{}, "encoding/gob.N2"}, | 173 {N2{}, "encoding/gob.N2"}, |
174 } | 174 } |
175 | 175 |
176 for _, tc := range testCases { | 176 for _, tc := range testCases { |
177 Register(tc.t) | 177 Register(tc.t) |
178 | 178 |
179 tct := reflect.TypeOf(tc.t) | 179 tct := reflect.TypeOf(tc.t) |
180 » » registerLock.Lock() | 180 » » registerLock.RLock() |
181 ct := nameToConcreteType[tc.name] | 181 ct := nameToConcreteType[tc.name] |
182 » » registerLock.Unlock() | 182 » » registerLock.RUnlock() |
183 if ct != tct { | 183 if ct != tct { |
184 t.Errorf("nameToConcreteType[%q] = %v, want %v", tc.name
, ct, tct) | 184 t.Errorf("nameToConcreteType[%q] = %v, want %v", tc.name
, ct, tct) |
185 } | 185 } |
186 // concreteTypeToName is keyed off the base type. | 186 // concreteTypeToName is keyed off the base type. |
187 if tct.Kind() == reflect.Ptr { | 187 if tct.Kind() == reflect.Ptr { |
188 tct = tct.Elem() | 188 tct = tct.Elem() |
189 } | 189 } |
190 if n := concreteTypeToName[tct]; n != tc.name { | 190 if n := concreteTypeToName[tct]; n != tc.name { |
191 t.Errorf("concreteTypeToName[%v] got %v, want %v", tct,
n, tc.name) | 191 t.Errorf("concreteTypeToName[%v] got %v, want %v", tct,
n, tc.name) |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
LEFT | RIGHT |