MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestLerp

Function TestLerp

math/lerp_test.go:9–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestLerp(t *testing.T) {
10 tests := []struct {
11 name string
12 testValues []float64
13 answer float64
14 }{
15 {"Lerp(1,1,1)", []float64{1, 1, 1}, 1},
16 {"Lerp(0,1,1)", []float64{0, 1, 1}, 1},
17 {"Lerp(0,1,0.5)", []float64{0, 1, 0.5}, 0.5},
18 {"Lerp(0,1,0.1)", []float64{0, 1, 0.1}, 0.1},
19 }
20 for _, test := range tests {
21 t.Run(test.name, func(t *testing.T) {
22 got := algmath.Lerp(test.testValues[0], test.testValues[1], test.testValues[2])
23 if got != test.answer {
24 t.Errorf("Lerp(%f,%f,%f) = %v, want %v", got, test.testValues[0],
25 test.testValues[1], test.testValues[2], test.answer)
26 }
27 })
28 }
29}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected