|
| 1 | +package dynamic_programming_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/anirudhology/leetcode-go/problems/dynamic_programming" |
| 7 | +) |
| 8 | + |
| 9 | +func TestMinDistanceEmptyStrings(t *testing.T) { |
| 10 | + result := dynamic_programming.EditDistance("", "") |
| 11 | + if result != 0 { |
| 12 | + t.Errorf("Expected 0, got %d", result) |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +func TestMinDistanceOneEmptyString(t *testing.T) { |
| 17 | + if result := dynamic_programming.EditDistance("hello", ""); result != 5 { |
| 18 | + t.Errorf("Expected 5, got %d", result) |
| 19 | + } |
| 20 | + if result := dynamic_programming.EditDistance("", "java"); result != 4 { |
| 21 | + t.Errorf("Expected 4, got %d", result) |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +func TestMinDistanceSameStrings(t *testing.T) { |
| 26 | + if result := dynamic_programming.EditDistance("same", "same"); result != 0 { |
| 27 | + t.Errorf("Expected 0, got %d", result) |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +func TestMinDistanceDifferentStrings(t *testing.T) { |
| 32 | + if result := dynamic_programming.EditDistance("horse", "ros"); result != 3 { |
| 33 | + t.Errorf("Expected 3, got %d", result) |
| 34 | + } |
| 35 | + if result := dynamic_programming.EditDistance("intention", "execution"); result != 5 { |
| 36 | + t.Errorf("Expected 5, got %d", result) |
| 37 | + } |
| 38 | + if result := dynamic_programming.EditDistance("flaw", "lawn"); result != 2 { |
| 39 | + t.Errorf("Expected 2, got %d", result) |
| 40 | + } |
| 41 | +} |
0 commit comments