-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilityfunctions_test.go
More file actions
52 lines (49 loc) · 1.19 KB
/
utilityfunctions_test.go
File metadata and controls
52 lines (49 loc) · 1.19 KB
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
package main
import (
"reflect"
"testing"
)
func TestReverseStringArray(t *testing.T) {
type args struct {
s []string
}
tests := []struct {
name string
args args
want []string
}{
{"empty", args{[]string{}}, []string{}},
{"one element", args{[]string{"a"}}, []string{"a"}},
{"three elements", args{[]string{"a", "b", "c"}}, []string{"c", "b", "a"}},
{"four elements", args{[]string{"a", "b", "c", "d"}}, []string{"d", "c", "b", "a"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ReverseStringArray(tt.args.s); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ReverseStringArray() = %v, want %v", got, tt.want)
}
})
}
}
func TestToValidHtmlAnchor(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add more test cases.
{"empty", args{""}, ""},
{"only valid", args{"abc_DEF-123"}, "abc_DEF-123"},
{"unvalid chars", args{"Fußnote 123.8$"}, "Fu_note_123_8_"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ToValidHtmlAnchor(tt.args.s); got != tt.want {
t.Errorf("ToValidHtmlAnchor() = %v, want %v", got, tt.want)
}
})
}
}