(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func 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 | |
| 119 | func TestGetRuneRange(t *testing.T) { |
| 120 | var ( |
nothing calls this directly
no test coverage detected