issue8694.go 966 B

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