This package provides a simple way to run parameterized tests:
import (
"math"
"testing"
"github.com/nitroshare/compare"
"github.com/nitroshare/params"
)
func TestSquareRoot(t *testing.T) {
type V struct {
Name string
Number float64
Root float64
}
Run(
t,
func(t *testing.T, v *V) {
if math.Sqrt(v.Number) != v.Root {
t.Fatal("root doesn't match!")
}
},
&V{
Name: "square root of nine",
Number: 9,
Root: 3,
},
)
}This package works extremely well in conjunction with the compare package