This is the mail archive of the mauve-patches@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java.text.SimpleDateFormat - new tests


I've added a couple of new tests for the java.text.SimpleDateFormat
class, specifically relating to the getDateFormatSymbols() and
setDateFormatSymbols() methods.  Also included are some minor checks for
the setXXX() methods in the DateFormatSymbols class.  See attached
patch.

Regards,

Dave Gilbert


Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.736
diff -u -r1.736 ChangeLog
--- ChangeLog	9 Nov 2004 15:04:37 -0000	1.736
+++ ChangeLog	11 Nov 2004 09:35:09 -0000
@@ -1,3 +1,17 @@
+2004-11-11  David Gilbert  <david.gilbert@object-refinery.com>
+
+	*
+	gnu/testlet/java/text/SimpleDateFormat/getDateFormatSymbols.java,
+	gnu/testlet/java/text/SimpleDateFormat/setDateFormatSymbols.java:
+	New tests;
+	* gnu/testlet/java/text/DateFormatSymbols/setAmPmStrings.java,
+	gnu/testlet/java/text/DateFormatSymbols/setEras.java,
+	gnu/testlet/java/text/DateFormatSymbols/setMonths.java,
+	gnu/testlet/java/text/DateFormatSymbols/setShortMonths.java,
+	gnu/testlet/java/text/DateFormatSymbols/setShortWeekdays.java,
+	gnu/testlet/java/text/DateFormatSymbols/setZoneStrings.java: New
+	tests.
+	
 2004-11-10  Stephen Crawley  <crawley@dstc.edu.au>
 
 	* gnu/testlet/SimpleTestHarness.java : minor tweak to a diagnostic
Index: gnu/testlet/java/text/DateFormatSymbols/setAmPmStrings.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setAmPmStrings.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setAmPmStrings.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setAmPmStrings.java	11 Nov 2004 09:35:13 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setAmPmStrings() method in the DateFormatSymbols
+ * class.  
+ */
+public class setAmPmStrings implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setAmPmStrings(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/DateFormatSymbols/setEras.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setEras.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setEras.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setEras.java	11 Nov 2004 09:35:13 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setEras() method in the DateFormatSymbols
+ * class.  
+ */
+public class setEras implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setEras(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/DateFormatSymbols/setMonths.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setMonths.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setMonths.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setMonths.java	11 Nov 2004 09:35:13 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setMonths() method in the DateFormatSymbols
+ * class.  
+ */
+public class setMonths implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setMonths(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/DateFormatSymbols/setShortMonths.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setShortMonths.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setShortMonths.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setShortMonths.java	11 Nov 2004 09:35:14 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setShortMonths() method in the DateFormatSymbols
+ * class.  
+ */
+public class setShortMonths implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setShortMonths(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/DateFormatSymbols/setShortWeekdays.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setShortWeekdays.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setShortWeekdays.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setShortWeekdays.java	11 Nov 2004 09:35:14 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setShortWeekdays() method in the DateFormatSymbols
+ * class.  
+ */
+public class setShortWeekdays implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setShortWeekdays(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/DateFormatSymbols/setWeekdays.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setWeekdays.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setWeekdays.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setWeekdays.java	11 Nov 2004 09:35:14 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setWeekdays() method in the DateFormatSymbols
+ * class.  
+ */
+public class setWeekdays implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setWeekdays(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/DateFormatSymbols/setZoneStrings.java
===================================================================
RCS file: gnu/testlet/java/text/DateFormatSymbols/setZoneStrings.java
diff -N gnu/testlet/java/text/DateFormatSymbols/setZoneStrings.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/DateFormatSymbols/setZoneStrings.java	11 Nov 2004 09:35:14 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.DateFormatSymbols;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.util.Locale;
+
+/**
+ * Some checks for the setZoneStrings() method in the DateFormatSymbols
+ * class.  
+ */
+public class setZoneStrings implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+   
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    DateFormatSymbols dfs = new DateFormatSymbols(Locale.UK);
+    try
+    {
+      dfs.setZoneStrings(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}
Index: gnu/testlet/java/text/SimpleDateFormat/getDateFormatSymbols.java
===================================================================
RCS file: gnu/testlet/java/text/SimpleDateFormat/getDateFormatSymbols.java
diff -N gnu/testlet/java/text/SimpleDateFormat/getDateFormatSymbols.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/SimpleDateFormat/getDateFormatSymbols.java	11 Nov 2004 09:35:14 -0000
@@ -0,0 +1,57 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.SimpleDateFormat;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Some checks for the getDateFormatSymbols() method in the SimpleDateFormat
+ * class.  
+ */
+public class getDateFormatSymbols implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+    // the getDateFormatSymbols() method should return a *copy* of the
+    // symbols, so updating them should not affect the results of the
+    // date formatter...
+    SimpleDateFormat sdf = new SimpleDateFormat("E", Locale.UK);
+    Date jan1_2005 = new Date(1104537600000L);
+    harness.check(sdf.format(jan1_2005), "Sat");
+    DateFormatSymbols s = sdf.getDateFormatSymbols();
+    s.setShortWeekdays(new String[] {"-", "S", "M", "T", "W", "T", "F", "S"});
+    harness.check(sdf.format(jan1_2005), "Sat");
+  }
+
+}
Index: gnu/testlet/java/text/SimpleDateFormat/setDateFormatSymbols.java
===================================================================
RCS file: gnu/testlet/java/text/SimpleDateFormat/setDateFormatSymbols.java
diff -N gnu/testlet/java/text/SimpleDateFormat/setDateFormatSymbols.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/text/SimpleDateFormat/setDateFormatSymbols.java	11 Nov 2004 09:35:15 -0000
@@ -0,0 +1,71 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.  */
+
+package gnu.testlet.java.text.SimpleDateFormat;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.text.DateFormatSymbols;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Some checks for the setDateFormatSymbols() method in the SimpleDateFormat
+ * class.  
+ */
+public class setDateFormatSymbols implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not allowed).
+   */
+  public void test(TestHarness harness)
+  {
+    // check that changing the short weekdays does work...
+    SimpleDateFormat sdf = new SimpleDateFormat("E", Locale.UK);
+    Date jan1_2005 = new Date(1104537600000L);
+    harness.check(sdf.format(jan1_2005), "Sat");
+    DateFormatSymbols s = sdf.getDateFormatSymbols();
+    s.setShortWeekdays(new String[] {"-", "S", "M", "T", "W", "T", "F", "S"});
+    // remember s is just a copy of the original
+    sdf.setDateFormatSymbols(s);
+    harness.check(sdf.format(jan1_2005), "S");
+    
+    // check null argument - it isn't mentioned in the spec that this
+    // should throw a NullPointerException, but that is such common
+    // behaviour elsewhere that I'm assuming this is the expected 
+    // result
+    try
+    {
+      sdf.setDateFormatSymbols(null);
+      harness.check(false);
+    }
+    catch (NullPointerException e)
+    {
+      harness.check(true);
+    }
+  }
+
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]