53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package fixture_test
|
|
|
|
import (
|
|
"testing"
|
|
"math"
|
|
"gitea.rosskeen.house/rosskeen.house/testing/fixture"
|
|
)
|
|
|
|
func Fixture2Pow(p fixture.Param) interface{} {
|
|
return math.Exp2(p.(float64))
|
|
}
|
|
|
|
func TestNewFixture(t *testing.T) {
|
|
f := fixture.New(t, Fixture2Pow, fixture.P([]fixture.Param{1.0,2.0,3.0}), fixture.R([]fixture.Result{2.0,4.0,8.0}))
|
|
|
|
f.RunWith(
|
|
func (t *testing.T) {
|
|
f.Fixture()
|
|
f.Assert()
|
|
})
|
|
|
|
}
|
|
|
|
func TargetMul2(input float64) float64 {
|
|
return input * 2
|
|
}
|
|
|
|
func TestAssertGe(t *testing.T) {
|
|
f := fixture.New(t, Fixture2Pow, fixture.P([]fixture.Param{1.0,2.0,3.0}), fixture.R([]fixture.Result{4.0,8.0,16.0}))
|
|
|
|
f.RunWith(
|
|
func (t *testing.T) {
|
|
pow := f.Value()
|
|
result := TargetMul2(pow.(float64))
|
|
f.AssertGe(float32(result))
|
|
})
|
|
|
|
}
|
|
|
|
func TestAssertEq(t *testing.T) {
|
|
f := fixture.New(t, Fixture2Pow, fixture.P([]fixture.Param{1.0,2.0,3.0}), fixture.R([]fixture.Result{4.0,8.0,16.0}))
|
|
|
|
f.RunWith(
|
|
func (t *testing.T) {
|
|
pow := f.Value()
|
|
result := TargetMul2(pow.(float64))
|
|
f.AssertEq(float32(result))
|
|
})
|
|
|
|
}
|