elision_ga_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2014 Couchbase, Inc.
  2. // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  3. // except in compliance with the License. You may obtain a copy of the License at
  4. // http://www.apache.org/licenses/LICENSE-2.0
  5. // Unless required by applicable law or agreed to in writing, software distributed under the
  6. // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  7. // either express or implied. See the License for the specific language governing permissions
  8. // and limitations under the License.
  9. package ga
  10. import (
  11. "reflect"
  12. "testing"
  13. "github.com/couchbaselabs/bleve/analysis"
  14. "github.com/couchbaselabs/bleve/registry"
  15. )
  16. func TestFrenchElision(t *testing.T) {
  17. tests := []struct {
  18. input analysis.TokenStream
  19. output analysis.TokenStream
  20. }{
  21. {
  22. input: analysis.TokenStream{
  23. &analysis.Token{
  24. Term: []byte("b'fhearr"),
  25. },
  26. },
  27. output: analysis.TokenStream{
  28. &analysis.Token{
  29. Term: []byte("fhearr"),
  30. },
  31. },
  32. },
  33. }
  34. cache := registry.NewCache()
  35. elisionFilter, err := cache.TokenFilterNamed(ElisionName)
  36. if err != nil {
  37. t.Fatal(err)
  38. }
  39. for _, test := range tests {
  40. actual := elisionFilter.Filter(test.input)
  41. if !reflect.DeepEqual(actual, test.output) {
  42. t.Errorf("expected %s, got %s", test.output[0].Term, actual[0].Term)
  43. }
  44. }
  45. }