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

Function TestI32EncodeDecodeBig

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

Source from the content-addressed store, hash-verified

1151}
1152
1153func TestI32EncodeDecodeBig(t *testing.T) {
1154
1155 n := 102400
1156 step := 2
1157 indexes := []int32{}
1158 elts := []int32{}
1159
1160 for i := 0; i < n; i += step {
1161 indexes = append(indexes, int32(i))
1162 elts = append(elts, int32(i))
1163 }
1164
1165 a, err := array.NewI32(indexes, elts)
1166 if err != nil {
1167 t.Errorf("expect no error but: %s", err)
1168 }
1169
1170 rst, err := proto.Marshal(a)
1171 if err != nil {
1172 t.Errorf("expect no error but: %s", err)
1173 }
1174
1175 b := &array.I32{}
1176 err = proto.Unmarshal(rst, b)
1177 if err != nil {
1178 t.Errorf("expect no error but: %s", err)
1179 }
1180
1181 // proto pollute this field
1182 a.XXX_sizecache = 0
1183 if !reflect.DeepEqual(a, b) {
1184 t.Fatalf("compare: a b: %v", pretty.Diff(a, b))
1185 }
1186}
1187
1188func BenchmarkI32Get(b *testing.B) {
1189 a, err := array.NewI32([]int32{1, 2, 3}, []int32{1, 2, 3})

Callers

nothing calls this directly

Calls 3

NewI32Function · 0.92
MarshalMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected