github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/misc/cgo/test/issue25143.go (about)

     1  // Copyright 2018 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  import "C"
     8  import "testing"
     9  
    10  func issue25143sum(ns ...C.int) C.int {
    11  	total := C.int(0)
    12  	for _, n := range ns {
    13  		total += n
    14  	}
    15  	return total
    16  }
    17  
    18  func test25143(t *testing.T) {
    19  	if got, want := issue25143sum(1, 2, 3), C.int(6); got != want {
    20  		t.Errorf("issue25143sum(1, 2, 3) == %v, expected %v", got, want)
    21  	}
    22  }