This package provides a simple way to run parameterized tests:
import (
"math""testing""github.com/nitroshare/compare""github.com/nitroshare/params"
)
funcTestSquareRoot(t*testing.T) {
typeVstruct {
NamestringNumberfloat64Rootfloat64
}
Run(
t,
func(t*testing.T, v*V) {
ifmath.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