[kaffe] CVS kaffe (dalibor): Improved DateFormat test case and implementations' error message
Kaffe CVS
cvs-commits at kaffe.org
Wed May 5 16:14:03 PDT 2004
PatchSet 4720
Date: 2004/05/05 23:01:18
Author: dalibor
Branch: HEAD
Tag: (none)
Log:
Improved DateFormat test case and implementations' error message
2004-05-05 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/text/DateFormat.java:
(parse) Improved error message.
* test/regression/DateFormatTest.java:
Improved error messages for failed tests.
Members:
ChangeLog:1.2294->1.2295
libraries/javalib/java/text/DateFormat.java:1.19->1.20
test/regression/DateFormatTest.java:1.1->1.2
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2294 kaffe/ChangeLog:1.2295
--- kaffe/ChangeLog:1.2294 Wed May 5 15:32:28 2004
+++ kaffe/ChangeLog Wed May 5 23:01:18 2004
@@ -1,5 +1,13 @@
2004-05-05 Dalibor Topic <robilad at kaffe.org>
+ * libraries/javalib/java/text/DateFormat.java:
+ (parse) Improved error message.
+
+ * test/regression/DateFormatTest.java:
+ Improved error messages for failed tests.
+
+2004-05-05 Dalibor Topic <robilad at kaffe.org>
+
* config/i386/freebsd2/md.h:
Added inclusion of sys/time.h to make kaffe compile on FreeBSD.
Index: kaffe/libraries/javalib/java/text/DateFormat.java
diff -u kaffe/libraries/javalib/java/text/DateFormat.java:1.19 kaffe/libraries/javalib/java/text/DateFormat.java:1.20
--- kaffe/libraries/javalib/java/text/DateFormat.java:1.19 Fri Apr 23 17:35:12 2004
+++ kaffe/libraries/javalib/java/text/DateFormat.java Wed May 5 23:01:20 2004
@@ -591,6 +591,7 @@
/**
* This method parses the specified date/time string.
*
+ * @param source The string to parse.
* @return The resultant date.
*
* @exception ParseException If the specified string cannot be parsed.
@@ -604,7 +605,7 @@
int index = pos.getErrorIndex();
if (index < 0)
index = pos.getIndex();
- throw new ParseException("invalid Date syntax", index);
+ throw new ParseException("invalid Date syntax in string \"" + source + '\"', index);
}
return result;
}
Index: kaffe/test/regression/DateFormatTest.java
diff -u kaffe/test/regression/DateFormatTest.java:1.1 kaffe/test/regression/DateFormatTest.java:1.2
--- kaffe/test/regression/DateFormatTest.java:1.1 Fri Feb 21 09:51:11 2003
+++ kaffe/test/regression/DateFormatTest.java Wed May 5 23:01:20 2004
@@ -2,6 +2,7 @@
import java.util.Date;
import java.util.SimpleTimeZone;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
public class DateFormatTest
@@ -17,13 +18,20 @@
sdf = new SimpleDateFormat("yyMMddHHmmssSSS");
date = new Date();
str = sdf.format(date);
- if( !date.equals(sdf.parse(str)) )
- {
- System.out.println("Dates don't match? "
- + date
- + " != "
- + sdf.parse(str));
- }
+
+ try {
+ if( !date.equals(sdf.parse(str)) )
+ {
+ System.out.println("Dates don't match? "
+ + date
+ + " != "
+ + sdf.parse(str));
+ }
+ }
+ catch (ParseException e) {
+ System.err.println("Parse error at position " + e.getErrorOffset());
+ e.printStackTrace();
+ }
SimpleTimeZone tz = new SimpleTimeZone(0, "Z");
SimpleDateFormat sdf2;
@@ -33,12 +41,19 @@
str = sdf.format(date);
str += "GMT+00:00";
sdf2 = new SimpleDateFormat("yyMMddHHmmssSSSz");
- if( !date.equals(sdf2.parse(str)) )
- {
- System.out.println("Dates don't match? "
- + date
- + " != "
- + sdf2.parse(str));
+
+ try {
+ if( !date.equals(sdf2.parse(str)) )
+ {
+ System.out.println("Dates don't match? "
+ + date
+ + " != "
+ + sdf2.parse(str));
+ }
+ }
+ catch (ParseException e) {
+ System.err.println("Parse error at position " + e.getErrorOffset());
+ e.printStackTrace();
}
}
}
More information about the kaffe
mailing list