Source file src/cmd/cgo/internal/test/issue8694.go

     1  // Copyright 2014 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 !android && !((ppc64 || ppc64le) && internal)
     6  
     7  package cgotest
     8  
     9  /*
    10  #include <complex.h>
    11  
    12  complex float complexFloatSquared(complex float a) { return a*a; }
    13  complex double complexDoubleSquared(complex double a) { return a*a; }
    14  */
    15  import "C"
    16  
    17  import (
    18  	"runtime"
    19  	"testing"
    20  )
    21  
    22  func test8694(t *testing.T) {
    23  	if runtime.GOARCH == "arm" {
    24  		t.Skip("test8694 is disabled on ARM because 5l cannot handle thumb library.")
    25  	}
    26  	// Really just testing that this compiles, but check answer anyway.
    27  	x := C.complexfloat(2 + 3i)
    28  	x2 := x * x
    29  	cx2 := C.complexFloatSquared(x)
    30  	if cx2 != x2 {
    31  		t.Errorf("C.complexFloatSquared(%v) = %v, want %v", x, cx2, x2)
    32  	}
    33  
    34  	y := C.complexdouble(2 + 3i)
    35  	y2 := y * y
    36  	cy2 := C.complexDoubleSquared(y)
    37  	if cy2 != y2 {
    38  		t.Errorf("C.complexDoubleSquared(%v) = %v, want %v", y, cy2, y2)
    39  	}
    40  }
    41  

View as plain text