MCPcopy Index your code
hub / github.com/apache/answer / TestFindFirstMatchedWord

Function TestFindFirstMatchedWord

pkg/htmltext/htmltext_test.go:90–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestFindFirstMatchedWord(t *testing.T) {
91 var (
92 expectedWord,
93 actualWord string
94 expectedIndex,
95 actualIndex int
96 )
97
98 text := "Hello, I have 中文 and 😂 and I am supposed to work fine."
99
100 // test find nothing
101 expectedWord, expectedIndex = "", 0
102 actualWord, actualIndex = findFirstMatchedWord(text, []string{"youcantfindme"})
103 assert.Equal(t, expectedWord, actualWord)
104 assert.Equal(t, expectedIndex, actualIndex)
105
106 // test find one word
107 expectedWord, expectedIndex = "文", 17
108 actualWord, actualIndex = findFirstMatchedWord(text, []string{"文"})
109 assert.Equal(t, expectedWord, actualWord)
110 assert.Equal(t, expectedIndex, actualIndex)
111
112 // test find multiple matched words
113 expectedWord, expectedIndex = "Hello", 0
114 actualWord, actualIndex = findFirstMatchedWord(text, []string{"Hello", "文"})
115 assert.Equal(t, expectedWord, actualWord)
116 assert.Equal(t, expectedIndex, actualIndex)
117}
118
119func TestGetRuneRange(t *testing.T) {
120 var (

Callers

nothing calls this directly

Calls 1

findFirstMatchedWordFunction · 0.85

Tested by

no test coverage detected