aboutsummaryrefslogtreecommitdiff
path: root/tests/legacy/examples/cgo/cgo_lib_test.go
blob: a486da6ad4bd1720990ea7ecbe91c925a74987e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package cgo

import (
	"math"
	"testing"
)

func TestNsqrt(t *testing.T) {
	for _, n := range []int{1, 2, 10, 100, 1000} {
		got, want := Nsqrt(n), int(math.Floor(math.Sqrt(float64(n))))
		if got != want {
			t.Errorf("Nsqrt(n) = %d; want %d", got, want)
		}
	}
}