(t *testing.T)
| 177 | } |
| 178 | |
| 179 | func TestKeywordSuggestionCacheConcurrency(t *testing.T) { |
| 180 | ClearSuggestionCache() |
| 181 | |
| 182 | var wg sync.WaitGroup |
| 183 | inputs := []string{"SELCT", "WHRE", "FRMO", "JION", "ORDR"} |
| 184 | |
| 185 | // Run multiple goroutines concurrently |
| 186 | for i := 0; i < 100; i++ { |
| 187 | wg.Add(1) |
| 188 | go func(idx int) { |
| 189 | defer wg.Done() |
| 190 | input := inputs[idx%len(inputs)] |
| 191 | _ = SuggestKeyword(input) |
| 192 | }(i) |
| 193 | } |
| 194 | |
| 195 | wg.Wait() |
| 196 | |
| 197 | // Cache should have at most len(inputs) entries |
| 198 | size := SuggestionCacheSize() |
| 199 | if size > len(inputs) { |
| 200 | t.Errorf("cache size = %d, want <= %d", size, len(inputs)) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | func BenchmarkSuggestKeywordWithCache(b *testing.B) { |
| 205 | ClearSuggestionCache() |
nothing calls this directly
no test coverage detected