(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestSin(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | n float64 |
| 13 | want float64 |
| 14 | }{ |
| 15 | {"sin(0)", 0, 0}, |
| 16 | {"sin(3π/2)", (3 * stdmath.Pi) / 2, -1}, |
| 17 | {"sin(π/2)", stdmath.Pi / 2, 1}, |
| 18 | {"sin(π/6)", stdmath.Pi / 6, 0.5}, |
| 19 | {"sin(90)", 90, 0.893996663600558}, |
| 20 | } |
| 21 | for _, test := range tests { |
| 22 | t.Run(test.name, func(t *testing.T) { |
| 23 | got := algmath.Sin(test.n) |
| 24 | if stdmath.Abs(got-test.want) >= epsilon { |
| 25 | t.Errorf("Sin() = %v, want %v", got, test.want) |
| 26 | t.Errorf("MATH Sin() = %v", stdmath.Sin(test.n)) |
| 27 | } |
| 28 | }) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | func BenchmarkSin(b *testing.B) { |
| 33 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no outgoing calls
no test coverage detected