-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathreverse_vowels_test.go
More file actions
36 lines (30 loc) · 918 Bytes
/
reverse_vowels_test.go
File metadata and controls
36 lines (30 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package strings
import "testing"
/*
TestReverseVowels tests solution(s) with the following signature and problem description:
func ReverseVowels(str string) (string, error)
Given a string, return the same string while reversing the vowels {"a", "e", "i", "o", "u"}
appear in it.
For example given "coat", return "caot", because the vowels are "o" and "a" and their positions
are reversed.
*/
func TestReverseVowels(t *testing.T) {
tests := []struct {
word string
reversed string
}{
{"umbrella", "ambrellu"},
{"coat", "caot"},
{"eventually", "avunteelly"},
{"sooner rather than later", "seanar rethar then lotor"},
}
for i, test := range tests {
got, err := ReverseVowels(test.word)
if err != nil {
t.Fatalf("Failed test case #%d. Unexpected Error. Error: %s", i, err)
}
if got != test.reversed {
t.Fatalf("Failed test case #%d. Want %q got %q", i, test.reversed, got)
}
}
}