-
Notifications
You must be signed in to change notification settings - Fork 0
/
characters_test.go
45 lines (34 loc) · 968 Bytes
/
characters_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
package main
import "testing"
import "strings"
func TestUTF8UnicodeLookup(t *testing.T) {
value := "a"
length := 10
characters := Characters{}
expected := strings.Repeat(value, length)
for i := 0; i <= length; i++ {
value := strings.Repeat(value, i)
characters[value] = value
}
result, _ := characters.UTF8UnicodeLookup(expected)
if len(result) > 1 {
t.Error("Multiple results are returned when one is expected")
}
if result[0] != expected {
t.Errorf("Unexpected result returned. Expected: %s, received %s\n", expected, result[0])
}
}
func TestUTF8LookupFirstMatch(t *testing.T) {
value := "a"
total := 10
characters := Characters{}
input := strings.Repeat(value, total/2)
for i := 0; i <= total; i++ {
value := strings.Repeat(value, i)
characters[value] = value
}
match, _ := UTF8LookupFirstMatch(input, characters)
if match != input {
t.Errorf("Unexpected result returned. Expected: %s, received %s\n", input, match)
}
}