Skip to content

Commit

Permalink
add math tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cpunion committed Nov 3, 2024
1 parent 390b92f commit 172edde
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions math/math_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package math

import (
"testing"

gp "github.com/cpunion/go-python"
)

func TestSqrt(t *testing.T) {
// Initialize Python
gp.Initialize()
defer gp.Finalize()

tests := []struct {
input float64
expected float64
}{
{16.0, 4.0},
{25.0, 5.0},
{0.0, 0.0},
{100.0, 10.0},
}

for _, test := range tests {
input := gp.MakeFloat(test.input)
result := Sqrt(input)

if result.Float64() != test.expected {
t.Errorf("Sqrt(%f) = %f; want %f", test.input, result.Float64(), test.expected)
}
}
}

0 comments on commit 172edde

Please sign in to comment.