2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.apache.lucene.analysis;
20 import java.io.StringReader;
22 import org.apache.lucene.util.LuceneTestCase;
24 public class TestCharFilter extends LuceneTestCase {
26 public void testCharFilter1() throws Exception {
27 CharStream cs = new CharFilter1( CharReader.get( new StringReader("") ) );
28 assertEquals( "corrected offset is invalid", 1, cs.correctOffset( 0 ) );
31 public void testCharFilter2() throws Exception {
32 CharStream cs = new CharFilter2( CharReader.get( new StringReader("") ) );
33 assertEquals( "corrected offset is invalid", 2, cs.correctOffset( 0 ) );
36 public void testCharFilter12() throws Exception {
37 CharStream cs = new CharFilter2( new CharFilter1( CharReader.get( new StringReader("") ) ) );
38 assertEquals( "corrected offset is invalid", 3, cs.correctOffset( 0 ) );
41 public void testCharFilter11() throws Exception {
42 CharStream cs = new CharFilter1( new CharFilter1( CharReader.get( new StringReader("") ) ) );
43 assertEquals( "corrected offset is invalid", 2, cs.correctOffset( 0 ) );
46 static class CharFilter1 extends CharFilter {
48 protected CharFilter1(CharStream in) {
53 protected int correct(int currentOff) {
54 return currentOff + 1;
58 static class CharFilter2 extends CharFilter {
60 protected CharFilter2(CharStream in) {
65 protected int correct(int currentOff) {
66 return currentOff + 2;