MCPcopy Create free account
hub / github.com/apache/pig / testSUM

Method testSUM

test/org/apache/pig/test/TestBuiltin.java:1422–1449  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1420 }
1421
1422 @Test
1423 public void testSUM() throws Exception {
1424 String[] sumTypes = {"SUM", "DoubleSum", "LongSum", "IntSum", "FloatSum", "BigDecimalSum", "BigIntegerSum"};
1425 for (int k = 0; k < sumTypes.length; k++) {
1426 EvalFunc<?> sum = evalFuncMap.get(sumTypes[k]);
1427 String inputType = getInputType(sumTypes[k]);
1428 Tuple tup = inputMap.get(inputType);
1429 Object output = sum.exec(tup);
1430
1431 String msg = "[Testing " + sumTypes[k] + " on input type: " + getInputType(sumTypes[k]) + " ( (output) " +
1432 output + " == " + getExpected(sumTypes[k]) + " (expected) )]";
1433
1434 if (inputType == "Integer" || inputType == "Long") {
1435 assertEquals(msg, (Long)output, (Long)getExpected(sumTypes[k]), 0.00001);
1436 }
1437 //Assert Equals does not support BigDecimal or BigInteger. Converting into String
1438 else if (inputType == "BigDecimal")
1439 assertEquals(msg, ((BigDecimal) output).toPlainString(), ((BigDecimal)getExpected(sumTypes[k])).toPlainString());
1440 else if (inputType == "BigInteger")
1441 assertEquals(msg, ((BigInteger) output).toString(), ((BigInteger)getExpected(sumTypes[k])).toString());
1442 else {
1443 assertEquals(msg, (Double)output, (Double)getExpected(sumTypes[k]), 0.00001);
1444 }
1445
1446 // Check null input
1447 assertNull(sum.exec(NULL_INPUT_TUPLE));
1448 }
1449 }
1450
1451 @Test
1452 public void testSUMIntermed() throws Exception {

Callers

nothing calls this directly

Calls 6

getInputTypeMethod · 0.95
getExpectedMethod · 0.95
getMethod · 0.65
execMethod · 0.45
assertEqualsMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected