Skip to content

Commit 172edde

Browse files
committed
add math tests
1 parent 390b92f commit 172edde

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

math/math_test.go

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package math
2+
3+
import (
4+
"testing"
5+
6+
gp "github.com/cpunion/go-python"
7+
)
8+
9+
func TestSqrt(t *testing.T) {
10+
// Initialize Python
11+
gp.Initialize()
12+
defer gp.Finalize()
13+
14+
tests := []struct {
15+
input float64
16+
expected float64
17+
}{
18+
{16.0, 4.0},
19+
{25.0, 5.0},
20+
{0.0, 0.0},
21+
{100.0, 10.0},
22+
}
23+
24+
for _, test := range tests {
25+
input := gp.MakeFloat(test.input)
26+
result := Sqrt(input)
27+
28+
if result.Float64() != test.expected {
29+
t.Errorf("Sqrt(%f) = %f; want %f", test.input, result.Float64(), test.expected)
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)