-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathsplit_test.go
72 lines (57 loc) · 2.82 KB
/
split_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
package swag
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestSplitter(t *testing.T) {
s := newSplitter(withPostSplitInitialismCheck)
t.Run("should return an empty slice of lexems", func(t *testing.T) {
lexems := s.split("")
poolOfLexems.RedeemLexems(lexems)
require.NotNil(t, lexems)
require.Empty(t, lexems)
})
}
func TestIsEqualFoldIgnoreSpace(t *testing.T) {
t.Run("should find equal", func(t *testing.T) {
require.True(t, isEqualFoldIgnoreSpace([]rune(""), ""))
require.True(t, isEqualFoldIgnoreSpace([]rune(""), " "))
require.True(t, isEqualFoldIgnoreSpace([]rune("A"), " a"))
require.True(t, isEqualFoldIgnoreSpace([]rune("A"), "a "))
require.True(t, isEqualFoldIgnoreSpace([]rune("A"), " a "))
require.True(t, isEqualFoldIgnoreSpace([]rune("A"), "\ta\t"))
require.True(t, isEqualFoldIgnoreSpace([]rune("A"), "a"))
require.True(t, isEqualFoldIgnoreSpace([]rune("A"), "\u00A0a\u00A0"))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), " ab"))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), "ab "))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), " ab "))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), " ab "))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), " AB"))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), "AB "))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), " AB "))
require.True(t, isEqualFoldIgnoreSpace([]rune("AB"), " AB "))
require.True(t, isEqualFoldIgnoreSpace([]rune("À"), " à"))
require.True(t, isEqualFoldIgnoreSpace([]rune("À"), "à "))
require.True(t, isEqualFoldIgnoreSpace([]rune("À"), " à "))
require.True(t, isEqualFoldIgnoreSpace([]rune("À"), " à "))
})
t.Run("should find different", func(t *testing.T) {
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), ""))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), ""))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), " b "))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), " b "))
require.False(t, isEqualFoldIgnoreSpace([]rune("AB"), " A B "))
require.False(t, isEqualFoldIgnoreSpace([]rune("AB"), " a b "))
require.False(t, isEqualFoldIgnoreSpace([]rune("AB"), " AB \u00A0\u00A0x"))
require.False(t, isEqualFoldIgnoreSpace([]rune("AB"), " AB \u00A0\u00A0é"))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), ""))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), ""))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), " b "))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), " b "))
require.False(t, isEqualFoldIgnoreSpace([]rune("A"), " à"))
require.False(t, isEqualFoldIgnoreSpace([]rune("À"), " bà"))
require.False(t, isEqualFoldIgnoreSpace([]rune("À"), "àb "))
require.False(t, isEqualFoldIgnoreSpace([]rune("À"), " a "))
require.False(t, isEqualFoldIgnoreSpace([]rune("À"), "Á"))
})
}