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

Method testByteArrayToOtherNoCast

test/org/apache/pig/test/TestPOCast.java:1860–2025  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1858 * the input to the cast is already a string
1859 */
1860 @Test
1861 public void testByteArrayToOtherNoCast() throws IOException {
1862 POCast op = new POCast(new OperatorKey("", r.nextLong()), -1);
1863 PhysicalPlan plan = constructPlan(op);
1864 TupleFactory tf = TupleFactory.getInstance();
1865
1866 {
1867 // create a new POCast each time since we
1868 // maintain a state variable per POCast object
1869 // indicating if cast is really required
1870 POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
1871 plan = constructPlan(newOp);
1872 Tuple t = tf.newTuple();
1873 Boolean input = new Boolean(r.nextBoolean());
1874 t.append(input);
1875 plan.attachInput(t);
1876 Result res = newOp.getNextBoolean();
1877 if(res.returnStatus == POStatus.STATUS_OK) {
1878 //System.out.println(res.result + " : " + i);
1879 assertEquals(input, res.result);
1880 }
1881
1882 t = tf.newTuple();
1883 t.append("neither true nor false");
1884 plan.attachInput(t);
1885 res = newOp.getNextBoolean();
1886 if(res.returnStatus == POStatus.STATUS_OK) {
1887 //System.out.println(res.result + " : " + i);
1888 assertEquals(null, res.result);
1889 }
1890 }
1891
1892 {
1893 Tuple t = tf.newTuple();
1894 Integer input = new Integer(r.nextInt());
1895 t.append(input);
1896 plan.attachInput(t);
1897 Result res = op.getNextInteger();
1898 if(res.returnStatus == POStatus.STATUS_OK) {
1899 //System.out.println(res.result + " : " + i);
1900 assertEquals(input, res.result);
1901 }
1902 }
1903
1904 {
1905 // create a new POCast each time since we
1906 // maintain a state variable per POCast object
1907 // indicating if cast is really required
1908 POCast newOp = new POCast(new OperatorKey("", r.nextLong()), -1);
1909 plan = constructPlan(newOp);
1910 Tuple t = tf.newTuple();
1911 Float input = new Float(r.nextFloat());
1912 t.append(input);
1913 plan.attachInput(t);
1914 Result res = newOp.getNextFloat();
1915 if(res.returnStatus == POStatus.STATUS_OK) {
1916 //System.out.println(res.result + " : " + i);
1917 assertEquals(input, res.result);

Callers

nothing calls this directly

Calls 15

constructPlanMethod · 0.95
getInstanceMethod · 0.95
newTupleMethod · 0.95
appendMethod · 0.95
attachInputMethod · 0.95
getNextBooleanMethod · 0.95
getNextIntegerMethod · 0.95
getNextFloatMethod · 0.95
getNextLongMethod · 0.95
getNextDoubleMethod · 0.95
getNextDateTimeMethod · 0.95
genRandSmallTupleMethod · 0.95

Tested by

no test coverage detected