(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func Test_NthFibonacci(t *testing.T) { |
| 9 | // source: http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibtable.html |
| 10 | var fibonacciNumbers = []struct { |
| 11 | nth uint |
| 12 | fibonacci uint |
| 13 | }{ |
| 14 | {0, 0}, |
| 15 | {1, 1}, |
| 16 | {2, 1}, |
| 17 | {3, 2}, |
| 18 | {4, 3}, |
| 19 | {5, 5}, |
| 20 | {6, 8}, |
| 21 | {7, 13}, |
| 22 | {8, 21}, |
| 23 | {9, 34}, |
| 24 | {10, 55}, |
| 25 | {20, 6765}, |
| 26 | {30, 832040}, |
| 27 | {40, 102334155}, |
| 28 | {50, 12586269025}, |
| 29 | {60, 1548008755920}, |
| 30 | {70, 190392490709135}, |
| 31 | {80, 23416728348467685}, |
| 32 | {90, 2880067194370816120}, |
| 33 | } |
| 34 | for i := range fibonacciNumbers { |
| 35 | t.Run(fmt.Sprintf("the %dth Fibonacci number", fibonacciNumbers[i].nth), func(t *testing.T) { |
| 36 | result := NthFibonacci(fibonacciNumbers[i].nth) |
| 37 | if result != fibonacciNumbers[i].fibonacci { |
| 38 | t.Errorf("Expected the %dth Fibonacci number to be %d, got %d", fibonacciNumbers[i].nth, fibonacciNumbers[i].fibonacci, result) |
| 39 | } |
| 40 | }) |
| 41 | } |
| 42 | } |
nothing calls this directly
no test coverage detected