(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func Test_EditDistance(t *testing.T) { |
| 9 | |
| 10 | var testCases = []struct { |
| 11 | first string |
| 12 | second string |
| 13 | expected int |
| 14 | }{ |
| 15 | {"", "", 0}, |
| 16 | {"horse", "ros", 3}, |
| 17 | {"intention", "execution", 5}, |
| 18 | {"abcdxabcde", "abcdeabcdx", 2}, |
| 19 | {"sunday", "saturday", 3}, |
| 20 | {"food", "money", 4}, |
| 21 | {"voldemort", "dumbledore", 7}, |
| 22 | } |
| 23 | |
| 24 | for i := range testCases { |
| 25 | |
| 26 | t.Run(fmt.Sprintf("Word 1: %s, Word 2: %s", testCases[i].first, testCases[i].second), func(t *testing.T) { |
| 27 | |
| 28 | computed := EditDistanceDP(testCases[i].first, testCases[i].second) |
| 29 | |
| 30 | if computed != testCases[i].expected { |
| 31 | t.Errorf("Word 1: %s, Word 2: %s, Expected: %d, Computed: %d", testCases[i].first, testCases[i].second, testCases[i].expected, computed) |
| 32 | } |
| 33 | }) |
| 34 | } |
| 35 | } |
nothing calls this directly
no test coverage detected