gitee.com/quant1x/num@v0.3.2/asm/c2goasm/cgocmp/CgoMultiplyAndAdd_test.go (about)

     1  package cgocmp
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestCgoMultiplyAndAdd(t *testing.T) {
     8  
     9  	f1 := [8]float32{}
    10  	f2 := [8]float32{}
    11  	f3 := [8]float32{}
    12  
    13  	for i := 0; i < 8; i++ {
    14  		f1[i] = float32(i)
    15  		f2[i] = float32(i * 2)
    16  		f3[i] = float32(i * 3)
    17  	}
    18  
    19  	f4 := CgoMultiplyAndAdd(&f1, &f2, &f3)
    20  
    21  	for i := 0; i < 8; i++ {
    22  		expected := f1[i]*f2[i] + f3[i]
    23  		if f4[i] != expected {
    24  			t.Errorf("TestCgoMultiplyAndAdd(): \nexpected %f\ngot      %f", expected, f4[i])
    25  		}
    26  	}
    27  }