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

Method testStringFuncs

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

Source from the content-addressed store, hash-verified

1776 }
1777
1778 @Test
1779 public void testStringFuncs() throws Exception {
1780 // Since String functions are trivial we add test on per case basis
1781 String inputStr = "Hello World!";
1782 String inputStrLower = "hello world!";
1783 String inputStrUpper = "HELLO WORLD!";
1784 String inputStrCamel = "hello World!";
1785 String inputStroWitha = "Hella Warld!";
1786 String inputStrSpaceRight = "Hello World! ";
1787 String inputStrSpaceLeft = " Hello World!";
1788 String inputStrSpaceBoth = " Hello World! ";
1789
1790 List<Object> l = new LinkedList<Object>();
1791 l.add(inputStr);
1792 l.add("o");
1793
1794 String expected = null;
1795 Tuple input;
1796 String output;
1797 Integer intOutput;
1798 EvalFunc<String> strFunc;
1799 EvalFunc<Integer> intFunc;
1800
1801 strFunc = new LCFIRST();
1802 input = TupleFactory.getInstance().newTuple(inputStr);
1803 expected = inputStrCamel;
1804 output = strFunc.exec(input);
1805 assertTrue(output.equals(expected));
1806
1807 strFunc = new UCFIRST();
1808 input = TupleFactory.getInstance().newTuple(inputStrCamel);
1809 expected = inputStr;
1810 output = strFunc.exec(input);
1811 assertTrue(output.equals(expected));
1812
1813 intFunc = new LAST_INDEX_OF();
1814 input = TupleFactory.getInstance().newTuple(l);
1815 intOutput = intFunc.exec(input);
1816 assertTrue(intOutput.intValue()==7);
1817
1818 intFunc = new INDEXOF();
1819 input = TupleFactory.getInstance().newTuple(l);
1820 intOutput = intFunc.exec(input);
1821 assertTrue(intOutput.intValue()==4);
1822
1823 strFunc = new UPPER();
1824 input = TupleFactory.getInstance().newTuple(inputStr);
1825 expected = inputStrUpper;
1826 output = strFunc.exec(input);
1827 assertTrue(output.equals(expected));
1828
1829 strFunc = new LOWER();
1830 input = TupleFactory.getInstance().newTuple(inputStr);
1831 expected = inputStrLower;
1832 output = strFunc.exec(input);
1833 assertTrue(output.equals(expected));
1834
1835 strFunc = new REPLACE();

Callers

nothing calls this directly

Calls 15

getInstanceMethod · 0.95
setMethod · 0.95
execMethod · 0.95
sizeMethod · 0.95
getMethod · 0.95
newTupleMethod · 0.95
execMethod · 0.95
execMethod · 0.95
execMethod · 0.95
createBagMethod · 0.95
buildTupleMethod · 0.95
addMethod · 0.65

Tested by

no test coverage detected