1
// Copyright (c) 2014 Couchbase, Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
21
"github.com/blevesearch/bleve/analysis"
24
func TestPersianNormalizeFilter(t *testing.T) {
26
input analysis.TokenStream
27
output analysis.TokenStream
31
input: analysis.TokenStream{
36
output: analysis.TokenStream{
44
input: analysis.TokenStream{
49
output: analysis.TokenStream{
57
input: analysis.TokenStream{
59
Term: []byte("کشاندن"),
62
output: analysis.TokenStream{
64
Term: []byte("كشاندن"),
70
input: analysis.TokenStream{
72
Term: []byte("كتابۀ"),
75
output: analysis.TokenStream{
77
Term: []byte("كتابه"),
83
input: analysis.TokenStream{
85
Term: []byte("كتابهٔ"),
88
output: analysis.TokenStream{
90
Term: []byte("كتابه"),
96
input: analysis.TokenStream{
101
output: analysis.TokenStream{
103
Term: []byte("زاده"),
109
input: analysis.TokenStream{
114
output: analysis.TokenStream{
122
persianNormalizeFilter := NewPersianNormalizeFilter()
123
for _, test := range tests {
124
actual := persianNormalizeFilter.Filter(test.input)
125
if !reflect.DeepEqual(actual, test.output) {
126
t.Errorf("expected %#v, got %#v", test.output, actual)
127
t.Errorf("expected % x, got % x", test.output[0].Term, actual[0].Term)