-
Notifications
You must be signed in to change notification settings - Fork 45
/
text_test.go
105 lines (83 loc) · 3.09 KB
/
text_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package gcse
import (
"testing"
"github.com/golangplus/testing/assert"
)
func TestSplitSentences(t *testing.T) {
TEXT := `
Package gcse is the core supporting library for go-code-search-engine (GCSE).
Its exported types and functions are mainly for sub packages. If you want
some of the function, copy the code away.
Sub-projects
crawler crawling packages
indexer creating index data for web-server
--== Godit - a very religious text editor ==--
server providing web services, including home/top/search services.
`
SENTS := []string{
`Package gcse is the core supporting library for go-code-search-engine (GCSE).`,
`Its exported types and functions are mainly for sub packages.`,
`If you want some of the function, copy the code away.`,
`Sub-projects`,
`crawler crawling packages`,
`indexer creating index data for web-server`,
`Godit - a very religious text editor`,
`server providing web services, including home/top/search services.`,
}
sents := SplitSentences(TEXT)
assert.StringEqual(t, "Sentences", sents, SENTS)
}
func TestChooseImportantSentenses(t *testing.T) {
TEXT := `
gcse implements something. If you want some of the function, copy the code away.
Package gcse provides something
daviddengcn/core is a something
github/daviddengcn/core is more than a something
-------------------------------------------------
This is a something
gcse是一个something
gcse 是一个something
is a framework to compare the performance of go 1.0 (go 1.0.3) and go 1.1 (go +tip).
这是一个something
非这是一个something2
the core package provides something
Go language implementation of selected algorithms from the
A simple pluggable lexer package.
`
IMPORTANTS := []string{
`gcse implements something.`,
`Package gcse provides something`,
`daviddengcn/core is a something`,
`github/daviddengcn/core is more than a something`,
`This is a something`,
`gcse是一个something`,
`gcse 是一个something`,
`is a framework to compare the performance of go 1.0 (go 1.0.3) and go 1.1 (go +tip).`,
`这是一个something`,
`the core package provides something`,
`Go language implementation of selected algorithms from the`,
`A simple pluggable lexer package.`,
}
importants := ChooseImportantSentenses(TEXT, "gcse", "github/daviddengcn/core")
assert.StringEqual(t, "importants", importants, IMPORTANTS)
}
func TestChooseImportantSentenses_GoBot(t *testing.T) {
TEXT := `
GoBot is an IRC Bot programmed in Golang![Build Status](https://secure.travis-ci.org/prometheus/client_golang.png?branch=master). It is designed to be lightweight and fast.
`
IMPORTANTS := []string{
`GoBot is an IRC Bot programmed in Golang.`,
}
importants := ChooseImportantSentenses(TEXT, "main", "github.com/wei2912/GoBot")
assert.StringEqual(t, "importants", importants, IMPORTANTS)
}
func TestChooseImportantSentenses_PackageEscape(t *testing.T) {
TEXT := `
GoBot is an IRC Bot programmed.
`
IMPORTANTS := []string{
`GoBot is an IRC Bot programmed.`,
}
importants := ChooseImportantSentenses(TEXT, "main", "github.com/+wei2912/GoBot")
assert.StringEqual(t, "importants", importants, IMPORTANTS)
}