/*
 * Copyright 2010 The Lucene Interval Field Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.greplin.interval;

import com.sun.tools.javac.util.Pair;
import org.apache.lucene.search.Searcher;
import org.junit.Test;

import java.io.IOException;

/**
 * Tests for the in numeric range query.
 */
public class InNumericIntervalQueryTest extends BaseIntervalQueryTest {

  private static final Pair<Long, Long> EXAMPLE = Pair.of(1257642000L, 1257645600L);

  private static final Pair<Long, Long> EDGE = Pair.of(1257642240L, 1257645568L);

  @Test
  public void testBasics() throws IOException {
    addDocument(1, EXAMPLE);

    Searcher searcher = getSearcher();
    assertSearch(searcher, 1257600000);
    assertSearch(searcher, 1257641999);
    assertSearch(searcher, 1257642000, 1);
    assertSearch(searcher, 1257644000, 1);
    assertSearch(searcher, 1257645600, 1);
    assertSearch(searcher, 1257645601);
  }

  @Test
  public void testEdge() throws IOException {
    addDocument(2, EDGE);

    Searcher searcher = getSearcher();
    assertSearch(searcher, 1257600000);
    assertSearch(searcher, 1257641999);
    assertSearch(searcher, 1257642000);
    assertSearch(searcher, 1257642239);
    assertSearch(searcher, 1257642240, 2);
    assertSearch(searcher, 1257644000, 2);
    assertSearch(searcher, 1257645568, 2);
    assertSearch(searcher, 1257645600);
    assertSearch(searcher, 1257645600);
    assertSearch(searcher, 1257645601);
  }

  @Test
  public void testMultiple() throws IOException {
    addDocument(1, EXAMPLE);
    addDocument(2, EDGE);

    Searcher searcher = getSearcher();
    assertSearch(searcher, 1257600000);
    assertSearch(searcher, 1257641999);
    assertSearch(searcher, 1257642000, 1);
    assertSearch(searcher, 1257642239, 1);
    assertSearch(searcher, 1257642240, 1, 2);
    assertSearch(searcher, 1257644000, 1, 2);
    assertSearch(searcher, 1257645568, 1, 2);
    assertSearch(searcher, 1257645600, 1);
    assertSearch(searcher, 1257645600, 1);
    assertSearch(searcher, 1257645601);
  }

  private void assertSearch(Searcher searcher, long value, Integer... expectedResults) throws IOException {
    assertSearch(searcher, new InNumericIntervalQuery("time", value), expectedResults);
  }
}

@@ -1067,24 +1067,173 @@
 568L);%0A%0A
+  private static final Pair%3CLong, Long%3E NEGATIVE = Pair.of(-100L, -50L);%0A%0A  private static final Pair%3CLong, Long%3E ACROSS_ZERO = Pair.of(-80L, 80L);%0A%0A
   @Test%0A
   public
@@ -1216,32 +1216,32 @@
  80L);%0A%0A  @Test%0A
-
   public void te
@@ -2121,32 +2121,623 @@
 57645601);%0A  %7D%0A%0A
+  @Test%0A  public void testNegative() throws IOException %7B%0A    addDocument(3, NEGATIVE);%0A    addDocument(4, ACROSS_ZERO);%0A%0A    Searcher searcher = getSearcher();%0A    assertSearch(searcher, -1000);%0A    assertSearch(searcher, 1000);%0A%0A    assertSearch(searcher, -101);%0A    assertSearch(searcher, -100, 3);%0A    assertSearch(searcher, -80, 3, 4);%0A    assertSearch(searcher, -50, 3, 4);%0A    assertSearch(searcher, -49, 4);%0A    assertSearch(searcher, -1, 4);%0A    assertSearch(searcher, 0, 4);%0A    assertSearch(searcher, 1, 4);%0A    assertSearch(searcher, 80, 4);%0A    assertSearch(searcher, 81);%0A  %7D%0A%0A
   @Test%0A  public
@@ -3303,21 +3303,22 @@
 45601);%0A
-
   %7D%0A%0A
+%0A
   privat

Add test case with negative values