testing/fixture/fixture_test.go

53 lines
1.2 KiB
Go
Raw Normal View History

2024-05-08 20:28:36 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
2024-05-08 21:08:10 +00:00
2024-05-08 20:28:36 +00:00
package fixture_test
import (
"testing"
"math"
2024-05-08 21:32:31 +00:00
"gitea.rosskeen.house/rosskeen.house/testing/fixture"
2024-05-08 20:28:36 +00:00
)
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))
})
}