-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathis_palindrome_test.go
More file actions
39 lines (33 loc) · 820 Bytes
/
is_palindrome_test.go
File metadata and controls
39 lines (33 loc) · 820 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
37
38
39
package recursion
import "testing"
/*
TestIsPalindrome tests solution(s) with the following signature and problem description:
func IsPalindrome(s string) bool
Given a string return true if it's a palindrome and false otherwise.
For example given `abba` return true. Given `abca` return false.
*/
func TestIsPalindrome(t *testing.T) {
tests := []struct {
s string
isPalindrome bool
}{
{"", true},
{"1", true},
{"a", true},
{"aa", true},
{"ab", false},
{"aba", true},
{"abba", true},
{"abca", false},
{"acba", false},
{"acca", true},
{"acdca", true},
{"acedeca", true},
{"acedec", false},
}
for i, test := range tests {
if got := IsPalindrome(test.s); got != test.isPalindrome {
t.Fatalf("Failed test case #%d. Want %t got %t", i, test.isPalindrome, got)
}
}
}