forked from xissy/lexorank
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lexorank_test.go
55 lines (45 loc) · 1.12 KB
/
lexorank_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
package lexorank
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSuccessEmptyPrevEmptyNext(t *testing.T) {
rank, ok := Rank("", "")
assert.Equal(t, "U", rank)
assert.Equal(t, true, ok)
}
func TestSuccessEmptyPrev(t *testing.T) {
rank, ok := Rank("", "2")
assert.Equal(t, "1", rank)
assert.Equal(t, true, ok)
}
func TestSuccessEmptyNext(t *testing.T) {
rank, ok := Rank("x", "")
assert.Equal(t, "y", rank)
assert.Equal(t, true, ok)
}
func TestSuccessNewDigit(t *testing.T) {
rank, ok := Rank("aaaa", "aaab")
assert.Equal(t, "aaaaU", rank)
assert.Equal(t, true, ok)
}
func TestSuccessMidValue(t *testing.T) {
rank, ok := Rank("aaaa", "aaac")
assert.Equal(t, "aaab", rank)
assert.Equal(t, true, ok)
}
func TestSuccessNewDigitMidValue(t *testing.T) {
rank, ok := Rank("az", "b")
assert.Equal(t, "azU", rank)
assert.Equal(t, true, ok)
}
func TestFailSamePrevNext(t *testing.T) {
rank, ok := Rank("aaaa", "aaaa")
assert.Equal(t, "aaaa", rank)
assert.Equal(t, false, ok)
}
func TestFailAdjacent(t *testing.T) {
rank, ok := Rank("a", "a0")
assert.Equal(t, "a", rank)
assert.Equal(t, false, ok)
}