(t *testing.T)
| 12 | } |
| 13 | |
| 14 | func TestTernaryMax(t *testing.T) { |
| 15 | |
| 16 | var tests = []struct { |
| 17 | f func(x float64) float64 |
| 18 | a float64 |
| 19 | b float64 |
| 20 | expected float64 |
| 21 | }{ |
| 22 | {f: func(x float64) float64 { return -x * x }, a: 1, b: -1, expected: 0}, |
| 23 | {f: func(x float64) float64 { return -2*x*x - x + 1 }, a: -1, b: 1, expected: 1.125}, |
| 24 | } |
| 25 | for _, test := range tests { |
| 26 | result, err := TernaryMax(test.a, test.b, EPS, test.f) |
| 27 | if err != nil { |
| 28 | t.Errorf("error occurred: %v", err) |
| 29 | } |
| 30 | if !equal(result, test.expected) { |
| 31 | t.Errorf("Wrong result! Expected:%v, returned:%v ", test.expected, result) |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func TestTernaryMin(t *testing.T) { |
| 37 |
nothing calls this directly
no test coverage detected