public void testUInt_withValidator() {
    final int[][] values =
        new int[][] {
          TestHelper.createUInts(
              new long[] {
                2147483644L,
                2147483645L,
                2147483646L,
                2147483647L,
                2147483648L,
                2147483649L,
                2147483650L,
                2147483651L
              }),
          TestHelper.createUInts(new long[] {2147483645L, 2147483647L, 2147483649L, 2147483651L}),
          TestHelper.createUInts(new long[] {2147483647L, 2147483648L, 2147483649L})
        };
    final boolean unsigned = true;
    final IndexValidator validator =
        new IndexValidator() {
          public boolean validateIndex(int index) {
            return index % 3 != 0;
          }
        };

    final Histogram histogram = new Histogram(new int[6], 2147483645, 2147483650L);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, validator, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {1, 1, 1, 2, 3, 0};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testUInt() {
    final int[][] values =
        new int[][] {
          TestHelper.createUInts(
              new long[] {
                2147483644L,
                2147483645L,
                2147483646L,
                2147483647L,
                2147483648L,
                2147483649L,
                2147483650L,
                2147483651L
              }),
          TestHelper.createUInts(new long[] {2147483645L, 2147483647L, 2147483649L, 2147483651L}),
          TestHelper.createUInts(new long[] {2147483647L, 2147483648L, 2147483649L})
        };
    final boolean unsigned = true;

    final Histogram histogram = new Histogram(new int[6], 2147483645, 2147483650L);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, IndexValidator.TRUE, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {2, 1, 3, 2, 3, 1};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testUByte() {
    final byte[][] values =
        new byte[][] {
          TestHelper.createUBytes(new short[] {124, 125, 126, 127, 128, 129, 130, 131}),
          TestHelper.createUBytes(new short[] {125, 127, 129, 131}),
          TestHelper.createUBytes(new short[] {127, 128, 129})
        };
    final boolean unsigned = true;

    final Histogram histogram = new Histogram(new int[6], 125, 130);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, IndexValidator.TRUE, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {2, 1, 3, 2, 3, 1};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testDoubleArray() {
    final DoubleList[] values =
        new DoubleList[] {
          TestHelper.createArray(new int[] {-3, -2, -1, 0, 1, 2, 3, 4}),
          TestHelper.createArray(new int[] {-2, 0, 2, 4}),
          TestHelper.createArray(new int[] {0, 1, 2})
        };
    final boolean unsigned = false;

    final Histogram histogram = new Histogram(new int[6], -2, 3);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, IndexValidator.TRUE, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {2, 1, 3, 2, 3, 1};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testUShort() {
    final short[][] values =
        new short[][] {
          TestHelper.createUShorts(
              new int[] {32764, 32765, 32766, 32767, 32768, 32769, 32770, 32771}),
          TestHelper.createUShorts(new int[] {32765, 32767, 32769, 32771}),
          TestHelper.createUShorts(new int[] {32767, 32768, 32769})
        };
    final boolean unsigned = true;

    final Histogram histogram = new Histogram(new int[6], 32765, 32770);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, IndexValidator.TRUE, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {2, 1, 3, 2, 3, 1};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testUByte_withValidator() {
    final byte[][] values =
        new byte[][] {
          TestHelper.createUBytes(new short[] {124, 125, 126, 127, 128, 129, 130, 131}),
          TestHelper.createUBytes(new short[] {125, 127, 129, 131}),
          TestHelper.createUBytes(new short[] {127, 128, 129})
        };
    final boolean unsigned = true;
    final IndexValidator validator =
        new IndexValidator() {
          public boolean validateIndex(int index) {
            return index % 3 != 0;
          }
        };

    final Histogram histogram = new Histogram(new int[6], 125, 130);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, validator, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {1, 1, 1, 2, 3, 0};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testDoubleArray_withValidator() {
    final DoubleList[] values =
        new DoubleList[] {
          TestHelper.createArray(new int[] {-3, -2, -1, 0, 1, 2, 3, 4}),
          TestHelper.createArray(new int[] {-2, 0, 2, 4}),
          TestHelper.createArray(new int[] {0, 1, 2})
        };
    final boolean unsigned = false;
    final IndexValidator validator =
        new IndexValidator() {
          public boolean validateIndex(int index) {
            return index % 3 != 0;
          }
        };

    final Histogram histogram = new Histogram(new int[6], -2, 3);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, validator, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {1, 1, 1, 2, 3, 0};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }
  public void testUShort_withValidator() {
    final short[][] values =
        new short[][] {
          TestHelper.createUShorts(
              new int[] {32764, 32765, 32766, 32767, 32768, 32769, 32770, 32771}),
          TestHelper.createUShorts(new int[] {32765, 32767, 32769, 32771}),
          TestHelper.createUShorts(new int[] {32767, 32768, 32769})
        };
    final boolean unsigned = true;
    final IndexValidator validator =
        new IndexValidator() {
          public boolean validateIndex(int index) {
            return index % 3 != 0;
          }
        };

    final Histogram histogram = new Histogram(new int[6], 32765, 32770);
    for (int i = 0; i < values.length; i++) {
      histogram.aggregate(values[i], unsigned, validator, ProgressMonitor.NULL);
    }

    final int[] exp = new int[] {1, 1, 1, 2, 3, 0};
    assertEquals("", equal(exp, histogram.getBinCounts()));
  }