github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/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      do {
    17          if (current_row == 10) {
    18              current_row = 0;
    19          }
    20          ++row_count;
    21      }
    22      while (current_row++ != 1);
    23      double d =  sqrt(sum_squares / row_count);
    24      printf("sqrt is: %g\n", d);
    25  }
    26  */
    27  import "C"
    28  import "testing"
    29  
    30  func test5986(t *testing.T) {
    31  	C.output5986()
    32  }