-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstringutils_test.go
58 lines (49 loc) · 1.11 KB
/
stringutils_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
package stringutils_test
import (
"fmt"
"testing"
"github.com/umuttopalak/stringutils"
)
func TestReverse(t *testing.T) {
tcs := map[string]struct {
input []string
want []string
}{
"none Turkish letters": {
input: []string{"hello", "this is vigo"},
want: []string{"olleh", "ogiv si siht"},
},
"with Turkish letters": {
input: []string{"uğur", "kırmızı şapka ve ÖĞRENCİ"},
want: []string{"ruğu", "İCNERĞÖ ev akpaş ızımrık"},
},
"with German letters": {
input: []string{"Präzisionsmeßgerät"},
want: []string{"täregßemsnoisizärP"},
},
}
for name, tc := range tcs {
t.Run(name, func(t *testing.T) {
for i, in := range tc.input {
got := stringutils.Reverse(in)
if got != tc.want[i] {
fmt.Println(len(got), len(tc.want[i]))
t.Errorf("want: %v; got: %v", tc.want[i], got)
}
}
})
}
}
var gs string
func BenchmarkReverse(b *testing.B) {
var s string
b.ResetTimer()
for i := 0; i < b.N; i++ {
s = stringutils.Reverse("merhaba dünya!")
}
gs = s
}
func ExampleReverse() {
fmt.Println(stringutils.Reverse("vigo"))
// Output: ogiv
}