add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / backwards / src / test / org / apache / lucene / analysis / TestCharFilter.java
1 /**
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 package org.apache.lucene.analysis;
19
20 import java.io.StringReader;
21
22 import org.apache.lucene.util.LuceneTestCase;
23
24 public class TestCharFilter extends LuceneTestCase {
25
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 ) );
29   }
30
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 ) );
34   }
35
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 ) );
39   }
40
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 ) );
44   }
45
46   static class CharFilter1 extends CharFilter {
47
48     protected CharFilter1(CharStream in) {
49       super(in);
50     }
51
52     @Override
53     protected int correct(int currentOff) {
54       return currentOff + 1;
55     }
56   }
57
58   static class CharFilter2 extends CharFilter {
59
60     protected CharFilter2(CharStream in) {
61       super(in);
62     }
63
64     @Override
65     protected int correct(int currentOff) {
66       return currentOff + 2;
67     }
68   }
69 }