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

Method testOperator

test/org/apache/pig/test/TestMultiply.java:50–296  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 }
49
50 @Test
51 public void testOperator() throws ExecException {
52 // int TRIALS = 10;
53 byte[] types = { DataType.BAG, DataType.BOOLEAN, DataType.BYTEARRAY, DataType.CHARARRAY,
54 DataType.DOUBLE, DataType.FLOAT, DataType.INTEGER, DataType.LONG,
55 DataType.DATETIME, DataType.MAP, DataType.TUPLE };
56 // Map<Byte,String> map = GenRandomData.genTypeToNameMap();
57 System.out.println("Testing Multiply operator");
58 for (byte type : types) {
59 lt.setResultType(type);
60 rt.setResultType(type);
61 op.setLhs(lt);
62 op.setRhs(rt);
63
64 switch (type) {
65 case DataType.BAG:
66 DataBag inpdb1 = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
67 DataBag inpdb2 = GenRandomData.genRandSmallTupDataBag(r, 10, 100);
68 lt.setValue(inpdb1);
69 rt.setValue(inpdb2);
70 Result resdb = op.getNextDataBag();
71 assertEquals(POStatus.STATUS_ERR, resdb.returnStatus);
72
73 // test with null in lhs
74 lt.setValue(null);
75 rt.setValue(inpdb2);
76 resdb = op.getNextDataBag();
77 assertEquals(POStatus.STATUS_ERR, resdb.returnStatus);
78 // test with null in rhs
79 lt.setValue(inpdb1);
80 rt.setValue(null);
81 resdb = op.getNextDataBag();
82 assertEquals(POStatus.STATUS_ERR, resdb.returnStatus);
83 break;
84 case DataType.BOOLEAN:
85 Boolean inpb1 = r.nextBoolean();
86 Boolean inpb2 = r.nextBoolean();
87 lt.setValue(inpb1);
88 rt.setValue(inpb2);
89 Result resb = op.getNextBoolean();
90 assertEquals(POStatus.STATUS_ERR, resb.returnStatus);
91
92 // test with null in lhs
93 lt.setValue(null);
94 rt.setValue(inpb2);
95 resb = op.getNextBoolean();
96 assertEquals(POStatus.STATUS_ERR, resb.returnStatus);
97 // test with null in rhs
98 lt.setValue(inpb1);
99 rt.setValue(null);
100 resb = op.getNextBoolean();
101 assertEquals(POStatus.STATUS_ERR, resb.returnStatus);
102 break;
103 case DataType.BYTEARRAY: {
104 DataByteArray inpba1 = GenRandomData.genRandDBA(r);
105 DataByteArray inpba2 = GenRandomData.genRandDBA(r);
106 lt.setValue(inpba1);
107 rt.setValue(inpba2);

Callers

nothing calls this directly

Calls 15

genRandDBAMethod · 0.95
genRandStringMethod · 0.95
genRandMapMethod · 0.95
genRandSmallBagTupleMethod · 0.95
getNextDataBagMethod · 0.65
getNextBooleanMethod · 0.65
getNextDataByteArrayMethod · 0.65
getNextStringMethod · 0.65
getNextDoubleMethod · 0.65
getNextFloatMethod · 0.65
getNextIntegerMethod · 0.65

Tested by

no test coverage detected