(t *testing.T)
| 34 | } |
| 35 | |
| 36 | func TestTernaryMin(t *testing.T) { |
| 37 | |
| 38 | var tests = []struct { |
| 39 | f func(x float64) float64 |
| 40 | a float64 |
| 41 | b float64 |
| 42 | expected float64 |
| 43 | }{ |
| 44 | {f: func(x float64) float64 { return x * x }, a: -1, b: 1, expected: 0}, |
| 45 | {f: func(x float64) float64 { return 2*x*x + x + 1 }, a: -1, b: 1, expected: 0.875}, |
| 46 | } |
| 47 | for _, test := range tests { |
| 48 | result, err := TernaryMin(test.a, test.b, EPS, test.f) |
| 49 | if err != nil { |
| 50 | t.Errorf("error occurred: %v", err) |
| 51 | } |
| 52 | if !equal(result, test.expected) { |
| 53 | t.Errorf("Wrong result! Expected:%v, returned:%v ", test.expected, result) |
| 54 | } |
| 55 | } |
| 56 | } |
nothing calls this directly
no test coverage detected