-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels_test.go
78 lines (63 loc) · 1.99 KB
/
models_test.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"testing"
)
func TestCleanStringToReturnOnlyCharactersInLowercase(t *testing.T) {
phrase := "Go hang a salami, I'm a lasagna hog"
expected := "gohangasalamiimalasagnahog"
actual := cleanString(phrase)
Expect(t, actual, expected)
}
func TestCleanStringToReturnCleanedJapaneseCharacters(t *testing.T) {
phrase := "たけやぶやけた"
expected := "たけやふやけた"
actual := cleanString(phrase)
Expect(t, actual, expected)
}
func TestCleanStringToReturnCleanedAccentCharacters(t *testing.T) {
phrase := "w͢͢͝h͡o͢͡ ̸͢k̵͟n̴͘ǫw̸̛s͘ ̀́w͘͢ḩ̵at ̧̕h́o̵r͏̵rors̡ ̶͡͠lį̶e͟͟ ̶͝in͢ ͏t̕h̷̡͟e ͟͟d̛a͜r̕͡k̢̨ ͡h̴e͏a̷̢̡rt́͏ ̴̷͠ò̵̶f̸ u̧͘ní̛͜c͢͏o̷͏d̸͢e̡͝?͞"
expected := "whoknowswhathorrorslieinthedarkheartofunicode"
actual := cleanString(phrase)
Expect(t, actual, expected)
}
func TestValidateAssertsPalindromes(t *testing.T) {
phrases := []string{
"Go hang a salami, I'm a lasagna hog",
"racecar",
"Rats live on no evil star",
"Live on time, emit no evil",
"Mr. Owl ate my metal worm",
"Was it a cat I saw?",
"Dammit I'm Mad",
"DÁBALE ARROZ A LA ZORRA EL ABAD",
"ROMA ME TEM AMOR",
"SOCORRAM-ME, SUBI NO ÔNIBUS EM MARROCOS",
"たけやぶやけた",
"わたしまけましたわ",
"なるとをとるな",
"しなもんぱんもれもんぱんもなし",
"よのなかほかほかなのよ",
"たしかにかした",
}
var palindrome Palindrome
for _, phrase := range phrases {
palindrome = Palindrome{Phrase: phrase}
palindrome.Validate()
Expect(t, palindrome.Valid, true)
}
}
func TestValidateRefutePalindromes(t *testing.T) {
phrases := []string{
"Not a valid palindrome",
"Just an usual phrase",
"Il n'y a pas qqch d'intéressant ici",
"Uma frase qualquer sem conexão",
"一期一会",
}
var palindrome Palindrome
for _, phrase := range phrases {
palindrome = Palindrome{Phrase: phrase}
palindrome.Validate()
Expect(t, palindrome.Valid, false)
}
}