test/java/sql/test/sql/TimeTests.java
Print this page
rev 10524 : 8055055: Improve numeric parsing in java.sql
*** 371,376 ****
--- 371,424 ----
public void test37() {
Time t = Time.valueOf("08:30:59");
Time t2 = new Time(t.getTime() + 1);
assertTrue(t.compareTo(t2) == -1, "Error t.compareTo(t2) != -1");
}
+
+ /**
+ * Validate that two Time values where one have omitted leading 0s
+ * for seconds are equal
+ */
+ @Test
+ public void test38() throws Exception {
+ String testTime = "10:50:0";
+ String expectedTime = "10:50:00";
+ Time t = Time.valueOf(testTime);
+ Time t2 = Time.valueOf(expectedTime);
+ assertEquals(t, t2, "Error t1 != t2");
+ }
+
+ /**
+ * Validate that two Time values where one have omitted leading 0s
+ * for minutes are equal
+ */
+ @Test
+ public void test39() throws Exception {
+ String testTime = "10:5:01";
+ String expectedTime = "10:05:01";
+ Time t = Time.valueOf(testTime);
+ Time t2 = Time.valueOf(expectedTime);
+ assertEquals(t, t2, "Error t1 != t2");
+ }
+
+ /**
+ * Validate that two Time values where one have omitted leading 0s
+ * for hour are equal
+ */
+ @Test
+ public void test40() throws Exception {
+ String testTime = "4:15:01";
+ String expectedTime = "04:15:01";
+ Time t = Time.valueOf(testTime);
+ Time t2 = Time.valueOf(expectedTime);
+ assertEquals(t, t2, "Error t1 != t2");
+ }
+
+ /**
+ * Validate an IllegalArgumentException is thrown for an invalid Time string
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void test41() throws Exception {
+ Time.valueOf("08:10:");
+ }
+
}