http://onsi.github.io/ginkgo/
package filter_test
import (
"bytes"
"strings"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("测试", func() {
var (
nodeFilter filter.DirtyFilter
filterText string
)
BeforeEach(func() {
filterText = `共产党泛指以马克思主义为指导以建立共产主义社会为目标的工人党。其中陈@@@水@@@扁。在。。`
})
It("替换", func() {
nodeFilter = filter.NewNodeFilter([]string{"共产主义"})
data, err := nodeFilter.Replace(filterText, '*')
if err != nil {
Fail(err.Error())
return
}
Expect(data).To(Equal(strings.Replace(filterText, "共产主义", "****", 1)))
})
})
网友评论