keywords = append(keywords, StringKeyword(vv))
case []string:
if toLower {
- for i := 0; i < len(vv); i++ {
- vv[i] = strings.ToLower(vv[i])
+ vc := make([]string, len(vv))
+ copy(vc, vv)
+ for i := 0; i < len(vc); i++ {
+ vc[i] = strings.ToLower(vc[i])
}
+ vv = vc
}
keywords = append(keywords, StringsToKeywords(vv...)...)
case time.Time:
}
+func TestToKeywordsToLower(t *testing.T) {
+ c := qt.New(t)
+ slice := []string{"A", "B", "C"}
+ config := IndexConfig{ToLower: true}
+ keywords, err := config.ToKeywords(slice)
+ c.Assert(err, qt.IsNil)
+ c.Assert(slice, qt.DeepEquals, []string{"A", "B", "C"})
+ c.Assert(keywords, qt.DeepEquals, []Keyword{
+ StringKeyword("a"),
+ StringKeyword("b"),
+ StringKeyword("c"),
+ })
+
+}
+
func BenchmarkRelatedNewIndex(b *testing.B) {
pages := make([]*testDoc, 100)