Index: hive-trunk/ql/src/test/org/apache/hadoop/hive/ql/udf/TestToInteger.java =================================================================== --- hive-trunk/ql/src/test/org/apache/hadoop/hive/ql/udf/TestToInteger.java (revision 0) +++ hive-trunk/ql/src/test/org/apache/hadoop/hive/ql/udf/TestToInteger.java (revision 0) @@ -0,0 +1,30 @@ +package org.apache.hadoop.hive.ql.udf; + +import junit.framework.TestCase; + +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.Text; +import org.junit.Test; + +public class TestToInteger extends TestCase{ + + @Test + public void testTextToInteger() throws Exception{ + UDFToInteger ti = new UDFToInteger(); + Text t1 = new Text("-1"); + IntWritable i1 = ti.evaluate(t1); + assertEquals(-1, i1.get()); + + Text t2 = new Text("0"); + IntWritable i2 = ti.evaluate(t2); + assertEquals(0, i2.get()); + + Text t3 = new Text("A"); + IntWritable i3 = ti.evaluate(t3); + assertNull(i3); + + Text t4 = new Text("1.1"); + IntWritable i4 = ti.evaluate(t4); + assertNull(i4); + } +} Index: hive-trunk/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFDateAdd.java =================================================================== --- hive-trunk/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFDateAdd.java (revision 1504279) +++ hive-trunk/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFDateAdd.java (working copy) @@ -18,12 +18,12 @@ package org.apache.hadoop.hive.ql.udf; -import org.apache.hadoop.io.IntWritable; -import org.apache.hadoop.io.Text; +import java.util.TimeZone; import junit.framework.TestCase; -import java.util.TimeZone; +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.Text; /** * JUnit test for UDFDateAdd. @@ -37,7 +37,7 @@ * on 2009-10-31. */ public void testFallBack() throws Exception { - // set the default time zone so that the dates cover + // set the default time zone so that the dates cover // the zone's daylight saving time adjustment (2009-10-31) // from daylight to standard time TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); @@ -55,7 +55,7 @@ * on 2010-03-14. */ public void testSpringAhead() throws Exception { - // set the default time zone so that the dates cover + // set the default time zone so that the dates cover // the zone's daylight saving time adjustment (2010-03-14) // from standard to daylight time TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));