Skip to content
Permalink
Browse files
test all input types
  • Loading branch information
AlexanderSaydakov committed Jul 11, 2017
1 parent a0749ad commit 3e18d39c7d3524b68cbffca16ddfde3cba52457b
Showing 1 changed file with 19 additions and 2 deletions.
@@ -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

0 comments on commit 3e18d39

Please sign in to comment.