-
Notifications
You must be signed in to change notification settings - Fork 7
/
paragraphs_test.go
68 lines (57 loc) · 1.53 KB
/
paragraphs_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
package gostrutils
import "testing"
func TestAbbreviateEmpty(t *testing.T) {
str := Abbreviate("", 0, 20, "")
if str != "" {
t.Errorf("Expected empty string, got '%s'", str)
}
}
func TestAbbreviateFour(t *testing.T) {
str := Abbreviate("four", 0, 20, "")
if str != "four" {
t.Errorf("Expected the return of 'four', gor '%s'", str)
}
}
func TestAbbreviateAbbrvChar(t *testing.T) {
str := Abbreviate("12345", 0, 5, ".....")
if str != "12345" {
t.Errorf("Expected '12345', got %s", str)
}
}
func TestAbbreviateValidLength(t *testing.T) {
str := Abbreviate("1234567890", 0, 10, "")
if str != "1234567890" {
t.Errorf("Expected '1234567890', got '%s'", str)
}
}
func TestAbbreviateOffestLength(t *testing.T) {
str := Abbreviate("1234567890", 11, 10, "")
if str != "1234567890" {
t.Errorf("Expected '1234567890', got '%s'", str)
}
}
func TestAbbreviateOffestLowerThenFour(t *testing.T) {
str := Abbreviate("1234567890", 0, 5, "")
if str != "1…0" {
t.Errorf("Expected '1…0', got '%s'", str)
}
}
func TestAbbreviateOffestHigherThenFour(t *testing.T) {
str := Abbreviate("1234567890", 5, 5, "")
if str != "1…6" {
t.Errorf("Expected '1…6', got '%s'", str)
}
}
func TestAbbreviateMaxLength(t *testing.T) {
str := Abbreviate("1234567890", 1, 0, "")
if str != "" {
t.Errorf("Expected empty string, got '%s'", str)
}
}
func TestAbbreviateStartLength(t *testing.T) {
str := Abbreviate("1234567890", 12, 5, DefaultEllipse)
expected := "1…0"
if str != expected {
t.Errorf("Expected '%s' got '%s'", expected, str)
}
}