diff options
Diffstat (limited to 'tests/legacy/examples/cgo/cgo_lib_test.go')
-rw-r--r-- | tests/legacy/examples/cgo/cgo_lib_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/legacy/examples/cgo/cgo_lib_test.go b/tests/legacy/examples/cgo/cgo_lib_test.go new file mode 100644 index 00000000..a486da6a --- /dev/null +++ b/tests/legacy/examples/cgo/cgo_lib_test.go @@ -0,0 +1,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) + } + } +} |