-
Notifications
You must be signed in to change notification settings - Fork 1
/
runes_test.go
49 lines (45 loc) · 2.33 KB
/
runes_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
package gana
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSkipRunes(t *testing.T) {
assert.Equal(t, "bc", SkipRunes[uint](1, "abc"), `"abc"[1:]`)
assert.Equal(t, "c", SkipRunes[uint](2, "abc"), `"abc"[2:]`)
assert.Equal(t, "", SkipRunes[uint](3, "abc"), `"abc"[3:]`)
assert.Equal(t, "", SkipRunes[uint](4, "abc"), `"abc"[4:]`)
assert.Equal(t, "abc", SkipRunes[uint](0, "abc"), `"abc"[0:]`)
assert.Equal(t, "", SkipRunes[uint](1, ""), `""[1:]`)
// Emojis
assert.Equal(t, "😀", SkipRunes[uint](1, "a😀"), `"a😀"[1:]`)
assert.Equal(t, "", SkipRunes[uint](2, "a😀"), `"a😀"[2:]`)
assert.Equal(t, "", SkipRunes[uint](3, "a😀"), `"a😀"[3:]`)
assert.Equal(t, "", SkipRunes[uint](4, "a😀"), `"a😀"[4:]`)
assert.Equal(t, "a😀", SkipRunes[uint](0, "a😀"), `"a😀"[0:]`)
// Complex emoji
assert.Equal(t, "😀😀", SkipRunes[uint](1, "a😀😀"), `"a😀😀"[1:]`)
assert.Equal(t, "😀", SkipRunes[uint](2, "a😀😀"), `"a😀😀"[2:]`)
assert.Equal(t, "", SkipRunes[uint](3, "a😀😀"), `"a😀😀"[3:]`)
assert.Equal(t, "", SkipRunes[uint](4, "a😀😀"), `"a😀😀"[4:]`)
assert.Equal(t, "a😀😀", SkipRunes[uint](0, "a😀😀"), `"a😀😀"[0:]`)
}
func TestDropRunes(t *testing.T) {
assert.Equal(t, "bc", DropRunes[uint](1, "abc"), `"abc"[1:]`)
assert.Equal(t, "c", DropRunes[uint](2, "abc"), `"abc"[2:]`)
assert.Equal(t, "", DropRunes[uint](3, "abc"), `"abc"[3:]`)
assert.Equal(t, "", DropRunes[uint](4, "abc"), `"abc"[4:]`)
assert.Equal(t, "abc", DropRunes[uint](0, "abc"), `"abc"[0:]`)
assert.Equal(t, "", DropRunes[uint](1, ""), `""[1:]`)
// Emojis
assert.Equal(t, "😀", DropRunes[uint](1, "a😀"), `"a😀"[1:]`)
assert.Equal(t, "", DropRunes[uint](2, "a😀"), `"a😀"[2:]`)
assert.Equal(t, "", DropRunes[uint](3, "a😀"), `"a😀"[3:]`)
assert.Equal(t, "", DropRunes[uint](4, "a😀"), `"a😀"[4:]`)
assert.Equal(t, "a😀", DropRunes[uint](0, "a😀"), `"a😀"[0:]`)
// Complex emoji
assert.Equal(t, "😀😀", DropRunes[uint](1, "a😀😀"), `"a😀😀"[1:]`)
assert.Equal(t, "😀", DropRunes[uint](2, "a😀😀"), `"a😀😀"[2:]`)
assert.Equal(t, "", DropRunes[uint](3, "a😀😀"), `"a😀😀"[3:]`)
assert.Equal(t, "", DropRunes[uint](4, "a😀😀"), `"a😀😀"[4:]`)
assert.Equal(t, "a😀😀", DropRunes[uint](0, "a😀😀"), `"a😀😀"[0:]`)
}