From 67914b14757bfe75ec4504a8e4e76197b85dd6d6 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Thu, 27 Sep 2012 02:46:55 +0000 Subject: [PATCH] Add some more tests git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1390815 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang3/time/FastDateParserTest.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index e2f12c101..5077ff2d9 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -333,6 +333,14 @@ public class FastDateParserTest { assertEquals(cal.getTime(), fdf.parse("'20030210A'B153320989'")); } + @Test + public void testSpecialCharacters() throws Exception { + testSdfAndFdp("q" ,"", true); // bad pattern character (at present) + testSdfAndFdp("Q" ,"", true); // bad pattern character + testSdfAndFdp("$" ,"$", false); // OK + testSdfAndFdp("?.d" ,"?.12", false); // OK + } + @Test public void testLANG_832() throws Exception { testSdfAndFdp("'d'd" ,"d3", false); // OK @@ -346,6 +354,7 @@ public class FastDateParserTest { private void testSdfAndFdp(String format, String date, boolean shouldFail) throws Exception { + final boolean debug = false; Date dfdp = null; Date dsdf = null; Throwable f = null; @@ -363,7 +372,9 @@ public class FastDateParserTest { if (!shouldFail) { throw e; } -// System.out.println("sdf:"+format+"/"+date+"=>"+e); + if (debug) { + System.out.println("sdf:"+format+"/"+date+"=>"+e); + } } try { @@ -377,11 +388,16 @@ public class FastDateParserTest { if (!shouldFail) { throw e; } -// System.out.println("fdf:"+format+"/"+date+"=>"+e); + if (debug) { + System.out.println("fdf:"+format+"/"+date+"=>"+e); + } } // SDF and FDF should produce equivalent results assertTrue("Should both or neither throw Exceptions", (f==null)==(s==null)); assertEquals("Parsed dates should be equal", dsdf, dfdp); + if (debug) { + System.out.println(format + "," + date + " => " + dsdf); + } } @Test