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

Method testOperator

test/org/apache/pig/test/TestDivide.java:55–344  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected