blob: f6185e857d7893821a885e7dd0fd0fa298fb14a2 [file] [log] [blame]
/*
* Copyright 2017, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.sketches.pig.hll;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.TupleFactory;
import org.testng.annotations.Test;
import com.yahoo.sketches.hll.HllSketch;
import junit.framework.Assert;
public class SketchToStringTest {
private static final TupleFactory tupleFactory = TupleFactory.getInstance();
@Test
public void nullInputTuple() throws Exception {
EvalFunc<String> func = new SketchToString();
String result = func.exec(null);
Assert.assertNull(result);
}
@Test
public void emptyInputTuple() throws Exception {
EvalFunc<String> func = new SketchToString();
String result = func.exec(tupleFactory.newTuple());
Assert.assertNull(result);
}
@Test
public void normalCase() throws Exception {
EvalFunc<String> func = new SketchToString();
HllSketch sketch = new HllSketch(12);
String result = func.exec(tupleFactory.newTuple(new DataByteArray(sketch.toCompactByteArray())));
Assert.assertNotNull(result);
Assert.assertTrue(result.length() > 0);
}
}