Exemple #1
0
  @Test
  public void testSelect() {

    for (int i = 0; i < 100; i++) {
      intColumn.add(i);
    }

    IntPredicate predicate = value -> value < 10;
    IntColumn column1 = intColumn.selectIf(predicate);
    assertEquals(10, column1.size());

    IntColumn column2 = intColumn.select(intColumn.select(predicate));
    assertEquals(10, column2.size());
    for (int i = 0; i < 10; i++) {
      assertTrue(column1.get(i) < 10);
    }
    for (int i = 0; i < 10; i++) {
      assertTrue(column2.get(i) < 10);
    }
  }
Exemple #2
0
  @Test
  public void testDifference() {
    int[] originalValues = new int[] {32, 42, 40, 57, 52};
    int[] expectedValues = new int[] {IntColumn.MISSING_VALUE, 10, -2, 17, -5};

    IntColumn initial = new IntColumn("Test", originalValues.length);
    for (int value : originalValues) {
      initial.add(value);
    }
    IntColumn difference = initial.difference();
    assertEquals(
        "Both sets of data should be the same size.", expectedValues.length, difference.size());
    for (int index = 0; index < difference.size(); index++) {
      int actual = difference.get(index);
      assertEquals(
          "difference operation at index:" + index + " failed", expectedValues[index], actual);
    }
  }