github.com/4ad/go@v0.0.0-20161219182952-69a12818b605/misc/cgo/test/issue5986.go (about)

     1  // Copyright 2013 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  package cgotest
     6  
     7  /*
     8  #cgo LDFLAGS: -lm
     9  #include <stdio.h>
    10  #include <math.h>
    11  
    12  static void output5986()
    13  {
    14      int current_row = 0, row_count = 0;
    15      double sum_squares = 0;
    16      double d;
    17      do {
    18          if (current_row == 10) {
    19              current_row = 0;
    20          }
    21          ++row_count;
    22      }
    23      while (current_row++ != 1);
    24      d =  sqrt(sum_squares / row_count);
    25      printf("sqrt is: %g\n", d);
    26  }
    27  */
    28  import "C"
    29  import "testing"
    30  
    31  func test5986(t *testing.T) {
    32  	C.output5986()
    33  }