/ pkg / util / subtitle_test.go
subtitle_test.go
 1  package util
 2  
 3  import (
 4  	"fmt"
 5  	"testing"
 6  )
 7  
 8  func TestSplitTextSentences(t *testing.T) {
 9  	origin_sentence := "Now, I'm Ryan D'Aris, founder and CEO of flowstate.com"
10  	sentences := SplitTextSentences(origin_sentence, 55)
11  	fmt.Println("origin sentence:", origin_sentence)
12  	for i, sentence := range sentences {
13  		fmt.Printf("sentence %d, got '%s'\n", i, sentence)
14  	}
15  
16  	// 期望的结果:应该保持为一个完整句子,因为有效字符数小于70
17  	if len(sentences) != 1 {
18  		t.Errorf("Expected 1 sentence, got %d sentences", len(sentences))
19  	}
20  }