add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / facet / src / test / org / apache / lucene / facet / search / TestFacetArrays.java
1 package org.apache.lucene.facet.search;
2
3 import org.junit.Test;
4
5 import org.apache.lucene.util.LuceneTestCase;
6 import org.apache.lucene.facet.search.FacetArrays;
7 import org.apache.lucene.facet.search.FloatArrayAllocator;
8 import org.apache.lucene.facet.search.IntArrayAllocator;
9
10 /**
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements.  See the NOTICE file distributed with
13  * this work for additional information regarding copyright ownership.
14  * The ASF licenses this file to You under the Apache License, Version 2.0
15  * (the "License"); you may not use this file except in compliance with
16  * the License.  You may obtain a copy of the License at
17  *
18  *     http://www.apache.org/licenses/LICENSE-2.0
19  *
20  * Unless required by applicable law or agreed to in writing, software
21  * distributed under the License is distributed on an "AS IS" BASIS,
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  * See the License for the specific language governing permissions and
24  * limitations under the License.
25  */
26
27 public class TestFacetArrays extends LuceneTestCase {
28
29   @Test
30   public void testSimple() {
31     FacetArrays arrays = new FacetArrays(new IntArrayAllocator(1, 1), new FloatArrayAllocator(1, 1));
32
33     int[] intArray = arrays.getIntArray();
34     // Set the element, then free
35     intArray[0] = 1;
36     arrays.free();
37
38     // We should expect a cleared array back
39     intArray = arrays.getIntArray();
40     assertEquals("Expected a cleared array back, but the array is still filled", 0, intArray[0]);
41
42     float[] floatArray = arrays.getFloatArray();
43     // Set the element, then free
44     floatArray[0] = 1.0f;
45     arrays.free();
46
47     // We should expect a cleared array back
48     floatArray = arrays.getFloatArray();
49     assertEquals("Expected a cleared array back, but the array is still filled", 0.0f, floatArray[0], 0.0);
50   }
51   
52 }