MCPcopy
hub / github.com/openacid/slim / TestU16EncodeDecodeBig

Function TestU16EncodeDecodeBig

array/int_test.go:209–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestU16EncodeDecodeBig(t *testing.T) {
210
211 n := 102400
212 step := 2
213 indexes := []int32{}
214 elts := []uint16{}
215
216 for i := 0; i < n; i += step {
217 indexes = append(indexes, int32(i))
218 elts = append(elts, uint16(i))
219 }
220
221 a, err := array.NewU16(indexes, elts)
222 if err != nil {
223 t.Errorf("expect no error but: %s", err)
224 }
225
226 rst, err := proto.Marshal(a)
227 if err != nil {
228 t.Errorf("expect no error but: %s", err)
229 }
230
231 b := &array.U16{}
232 err = proto.Unmarshal(rst, b)
233 if err != nil {
234 t.Errorf("expect no error but: %s", err)
235 }
236
237 // proto pollute this field
238 a.XXX_sizecache = 0
239 if !reflect.DeepEqual(a, b) {
240 t.Fatalf("compare: a b: %v", pretty.Diff(a, b))
241 }
242}
243
244func BenchmarkU16Get(b *testing.B) {
245 a, err := array.NewU16([]int32{1, 2, 3}, []uint16{1, 2, 3})

Callers

nothing calls this directly

Calls 3

NewU16Function · 0.92
MarshalMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected