@@ -47,11 +47,7 @@ func TestType(t *testing.T) {
4747
4848 got := [4 ]int32 {}
4949 v .y .Store (& got )
50- for i := range 4 {
51- if want [i ] != got [i ] {
52- t .Errorf ("Result at %d incorrect: want %d, got %d" , i , want [i ], got [i ])
53- }
54- }
50+ checkSlices (t , got [:], want )
5551}
5652
5753func TestUncomparable (t * testing.T ) {
@@ -80,11 +76,7 @@ func TestFuncValue(t *testing.T) {
8076 x = fn (x , y )
8177 got := [4 ]int32 {}
8278 x .Store (& got )
83- for i := range 4 {
84- if want [i ] != got [i ] {
85- t .Errorf ("Result at %d incorrect: want %d, got %d" , i , want [i ], got [i ])
86- }
87- }
79+ checkSlices (t , got [:], want )
8880}
8981
9082func TestReflectMethod (t * testing.T ) {
@@ -103,11 +95,7 @@ func TestReflectMethod(t *testing.T) {
10395 x = fn (x , y )
10496 got := [4 ]int32 {}
10597 x .Store (& got )
106- for i := range 4 {
107- if want [i ] != got [i ] {
108- t .Errorf ("Result at %d incorrect: want %d, got %d" , i , want [i ], got [i ])
109- }
110- }
98+ checkSlices (t , got [:], want )
11199}
112100
113101func TestVectorConversion (t * testing.T ) {
@@ -139,11 +127,7 @@ func TestMaskConversion(t *testing.T) {
139127 want := [4 ]int32 {6 , 0 , 10 , 0 }
140128 got := make ([]int32 , 4 )
141129 y .StoreSlice (got )
142- for i := range 4 {
143- if want [i ] != got [i ] {
144- t .Errorf ("Result at %d incorrect: want %d, got %d" , i , want [i ], got [i ])
145- }
146- }
130+ checkSlices (t , got [:], want [:])
147131}
148132
149133func TestPermute (t * testing.T ) {
@@ -156,11 +140,7 @@ func TestPermute(t *testing.T) {
156140 want := []int64 {8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 }
157141 got := make ([]int64 , 8 )
158142 simd .LoadInt64x8Slice (x ).Permute (simd .LoadUint64x8Slice (indices )).StoreSlice (got )
159- for i := range 8 {
160- if want [i ] != got [i ] {
161- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
162- }
163- }
143+ checkSlices (t , got , want )
164144}
165145
166146func TestPermuteOrZero (t * testing.T ) {
@@ -169,11 +149,7 @@ func TestPermuteOrZero(t *testing.T) {
169149 want := []uint8 {8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 , 9 , 0 , 10 , 0 , 11 , 0 , 12 }
170150 got := make ([]uint8 , len (x ))
171151 simd .LoadUint8x16Slice (x ).PermuteOrZero (simd .LoadInt8x16Slice (indices )).StoreSlice (got )
172- for i := range 8 {
173- if want [i ] != got [i ] {
174- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
175- }
176- }
152+ checkSlices (t , got , want )
177153}
178154
179155func TestConcatPermute (t * testing.T ) {
@@ -187,11 +163,7 @@ func TestConcatPermute(t *testing.T) {
187163 want := []int64 {- 8 , 7 , - 6 , 5 , - 4 , 3 , - 2 , 1 }
188164 got := make ([]int64 , 8 )
189165 simd .LoadInt64x8Slice (x ).ConcatPermute (simd .LoadInt64x8Slice (y ), simd .LoadUint64x8Slice (indices )).StoreSlice (got )
190- for i := range 8 {
191- if want [i ] != got [i ] {
192- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
193- }
194- }
166+ checkSlices (t , got , want )
195167}
196168
197169func TestCompress (t * testing.T ) {
@@ -1180,69 +1152,45 @@ func TestPermuteScalars(t *testing.T) {
11801152 want := []int32 {12 , 13 , 14 , 11 }
11811153 got := make ([]int32 , 4 )
11821154 simd .LoadInt32x4Slice (x ).PermuteScalars (1 , 2 , 3 , 0 ).StoreSlice (got )
1183- for i := range 4 {
1184- if want [i ] != got [i ] {
1185- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
1186- }
1187- }
1155+ checkSlices (t , got , want )
11881156}
11891157
11901158func TestPermuteScalarsGrouped (t * testing.T ) {
11911159 x := []int32 {11 , 12 , 13 , 14 , 21 , 22 , 23 , 24 }
11921160 want := []int32 {12 , 13 , 14 , 11 , 22 , 23 , 24 , 21 }
11931161 got := make ([]int32 , 8 )
11941162 simd .LoadInt32x8Slice (x ).PermuteScalarsGrouped (1 , 2 , 3 , 0 ).StoreSlice (got )
1195- for i := range 8 {
1196- if want [i ] != got [i ] {
1197- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
1198- }
1199- }
1163+ checkSlices (t , got , want )
12001164}
12011165
12021166func TestPermuteScalarsHi (t * testing.T ) {
12031167 x := []int16 {- 1 , - 2 , - 3 , - 4 , 11 , 12 , 13 , 14 }
12041168 want := []int16 {- 1 , - 2 , - 3 , - 4 , 12 , 13 , 14 , 11 }
12051169 got := make ([]int16 , len (x ))
12061170 simd .LoadInt16x8Slice (x ).PermuteScalarsHi (1 , 2 , 3 , 0 ).StoreSlice (got )
1207- for i := range got {
1208- if want [i ] != got [i ] {
1209- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
1210- }
1211- }
1171+ checkSlices (t , got , want )
12121172}
12131173
12141174func TestPermuteScalarsLo (t * testing.T ) {
12151175 x := []int16 {11 , 12 , 13 , 14 , 4 , 5 , 6 , 7 }
12161176 want := []int16 {12 , 13 , 14 , 11 , 4 , 5 , 6 , 7 }
12171177 got := make ([]int16 , len (x ))
12181178 simd .LoadInt16x8Slice (x ).PermuteScalarsLo (1 , 2 , 3 , 0 ).StoreSlice (got )
1219- for i := range got {
1220- if want [i ] != got [i ] {
1221- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
1222- }
1223- }
1179+ checkSlices (t , got , want )
12241180}
12251181
12261182func TestPermuteScalarsHiGrouped (t * testing.T ) {
12271183 x := []int16 {- 1 , - 2 , - 3 , - 4 , 11 , 12 , 13 , 14 , - 11 , - 12 , - 13 , - 14 , 111 , 112 , 113 , 114 }
12281184 want := []int16 {- 1 , - 2 , - 3 , - 4 , 12 , 13 , 14 , 11 , - 11 , - 12 , - 13 , - 14 , 112 , 113 , 114 , 111 }
12291185 got := make ([]int16 , len (x ))
12301186 simd .LoadInt16x16Slice (x ).PermuteScalarsHiGrouped (1 , 2 , 3 , 0 ).StoreSlice (got )
1231- for i := range got {
1232- if want [i ] != got [i ] {
1233- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
1234- }
1235- }
1187+ checkSlices (t , got , want )
12361188}
12371189
12381190func TestPermuteScalarsLoGrouped (t * testing.T ) {
12391191 x := []int16 {11 , 12 , 13 , 14 , 4 , 5 , 6 , 7 , 111 , 112 , 113 , 114 , 14 , 15 , 16 , 17 }
12401192 want := []int16 {12 , 13 , 14 , 11 , 4 , 5 , 6 , 7 , 112 , 113 , 114 , 111 , 14 , 15 , 16 , 17 }
12411193 got := make ([]int16 , len (x ))
12421194 simd .LoadInt16x16Slice (x ).PermuteScalarsLoGrouped (1 , 2 , 3 , 0 ).StoreSlice (got )
1243- for i := range got {
1244- if want [i ] != got [i ] {
1245- t .Errorf ("want and got differ at index %d, want=%d, got=%d" , i , want [i ], got [i ])
1246- }
1247- }
1195+ checkSlices (t , got , want )
12481196}
0 commit comments