Skip to content

Commit

Permalink
test all input types
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSaydakov committed Jul 11, 2017
1 parent a0749ad commit 3e18d39
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/test/java/com/yahoo/sketches/pig/hll/DataToSketchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,32 @@ public void execEmptyBag() throws Exception {
Assert.assertTrue(sketch.isEmpty());
}

@Test(expectedExceptions = IllegalArgumentException.class)
public void execUnsupportedType() throws Exception {
EvalFunc<DataByteArray> func = new DataToSketch();
DataBag bag = bagFactory.newDefaultBag();
bag.add(tupleFactory.newTuple(new Object()));
func.exec(tupleFactory.newTuple(bag));
}

@Test
public void execNormalCase() throws Exception {
public void execVariousTypesOfInput() throws Exception {
EvalFunc<DataByteArray> func = new DataToSketch();
DataBag bag = bagFactory.newDefaultBag();
Tuple tupleWithNull = tupleFactory.newTuple(1);
tupleWithNull.set(0, null);
bag.add(tupleWithNull);
bag.add(tupleFactory.newTuple(new Byte((byte) 1)));
bag.add(tupleFactory.newTuple(new Integer(2)));
bag.add(tupleFactory.newTuple(new Long(3)));
bag.add(tupleFactory.newTuple(new Float(1)));
bag.add(tupleFactory.newTuple(new Double(2)));
bag.add(tupleFactory.newTuple(new DataByteArray(new byte[] {(byte) 1})));
bag.add(tupleFactory.newTuple("a"));
DataByteArray result = func.exec(tupleFactory.newTuple(bag));
HllSketch sketch = getSketch(result);
Assert.assertFalse(sketch.isEmpty());
Assert.assertEquals(sketch.getEstimate(), 1.0, 0.01);
Assert.assertEquals(sketch.getEstimate(), 7.0, 0.01);
}

@Test
Expand Down

0 comments on commit 3e18d39

Please sign in to comment.