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