Source file src/simd/archsimd/internal/simd_test/array_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build goexperiment.simd && (amd64 || arm64 || wasm)
     6  
     7  package simd_test
     8  
     9  import (
    10  	"simd/archsimd"
    11  	"testing"
    12  )
    13  
    14  var int8x16Sink archsimd.Int8x16
    15  
    16  func expectPanic(t *testing.T, f func()) {
    17  	t.Helper()
    18  	defer func() {
    19  		if recover() == nil {
    20  			t.Error("did not panic")
    21  		}
    22  	}()
    23  	f()
    24  }
    25  
    26  func TestArrayNilChecks(t *testing.T) {
    27  	t.Run("load", func(t *testing.T) {
    28  		expectPanic(t, func() {
    29  			int8x16Sink = archsimd.LoadInt8x16Array(nil)
    30  		})
    31  	})
    32  	t.Run("store", func(t *testing.T) {
    33  		expectPanic(t, func() {
    34  			var a [16]int8
    35  			archsimd.LoadInt8x16Array(&a).StoreArray(nil)
    36  		})
    37  	})
    38  }
    39  

View as plain text