(t *testing.T)
| 8 | import "testing" |
| 9 | |
| 10 | func TestUsingLog(t *testing.T) { |
| 11 | var tests = []struct { |
| 12 | name string |
| 13 | base float64 |
| 14 | power float64 |
| 15 | expected float64 |
| 16 | }{ |
| 17 | {"0^0", 99, 1, 99}, |
| 18 | {"-3^9", -3, 9, -19683}, |
| 19 | {"0^2", 0, 2, 0}, |
| 20 | {"2^0", 2, 0, 1}, |
| 21 | {"2^3", 2, 3, 8}, |
| 22 | {"8^3", 8, 3, 512}, |
| 23 | {"11^11", 11, 11, 285311670611}, |
| 24 | {"5^5", 5, 5, 3125}, |
| 25 | {"-7^2", -7, 2, 49}, |
| 26 | {"-6^3", -6, 3, -216}, |
| 27 | } |
| 28 | |
| 29 | for _, tc := range tests { |
| 30 | t.Run(tc.name, func(t *testing.T) { |
| 31 | result := UsingLog(tc.base, tc.power) |
| 32 | t.Log(result) |
| 33 | if result != tc.expected { |
| 34 | t.Errorf("Expected %.2f to the power of %.2f to be: %.2f, but got: %.2f", tc.base, tc.power, tc.expected, result) |
| 35 | } |
| 36 | }) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | func BenchmarkUsingLog(b *testing.B) { |
| 41 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no test coverage detected