~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/backwards/src/test/org/apache/lucene/util/TestCharsRef.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.util;
2
 
 
3
 
import java.util.Arrays;
4
 
 
5
 
/**
6
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
7
 
 * contributor license agreements.  See the NOTICE file distributed with
8
 
 * this work for additional information regarding copyright ownership.
9
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
10
 
 * (the "License"); you may not use this file except in compliance with
11
 
 * the License.  You may obtain a copy of the License at
12
 
 *
13
 
 *     http://www.apache.org/licenses/LICENSE-2.0
14
 
 *
15
 
 * Unless required by applicable law or agreed to in writing, software
16
 
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 
 * See the License for the specific language governing permissions and
19
 
 * limitations under the License.
20
 
 */
21
 
 
22
 
public class TestCharsRef extends LuceneTestCase {
23
 
  public void testUTF16InUTF8Order() {
24
 
    final int numStrings = atLeast(1000);
25
 
    BytesRef utf8[] = new BytesRef[numStrings];
26
 
    CharsRef utf16[] = new CharsRef[numStrings];
27
 
    
28
 
    for (int i = 0; i < numStrings; i++) {
29
 
      String s = _TestUtil.randomUnicodeString(random);
30
 
      utf8[i] = new BytesRef(s);
31
 
      utf16[i] = new CharsRef(s);
32
 
    }
33
 
    
34
 
    Arrays.sort(utf8);
35
 
    Arrays.sort(utf16, CharsRef.getUTF16SortedAsUTF8Comparator());
36
 
    
37
 
    for (int i = 0; i < numStrings; i++) {
38
 
      assertEquals(utf8[i].utf8ToString(), utf16[i].toString());
39
 
    }
40
 
  }
41
 
}