示例#1
0
func TestBytesRemoveUntil(t *testing.T) {
	for _, td := range dataCut {
		got, _ := tekstus.BytesRemoveUntil([]byte(td.text),
			[]byte(td.leftcap), []byte(td.rightcap))

		assert(t, string(td.exp), string(got), true)
	}
}
示例#2
0
// Compute will count number of bytes that is used in comment, NOT including
// the header content "/* ... */".
func (ftr *CommentLength) Compute(dataset tabula.DatasetInterface) {
	col := dataset.GetColumnByName("editcomment")
	leftcap := []byte("/*")
	rightcap := []byte("*/")

	for _, rec := range col.Records {
		cmt := rec.Bytes()

		cmt, _ = tekstus.BytesRemoveUntil(cmt, leftcap, rightcap)

		ftr.PushBack(tabula.NewRecordInt(int64(len(cmt))))
	}
}