From: Gary Benson <gbenson@redhat.com>
To: mauve-patches@sources.redhat.com
Subject: FYI: More GregorianCalendar day of week in month checks
Date: Thu, 05 Apr 2007 13:32:00 -0000 [thread overview]
Message-ID: <20070405133156.GD25259@redhat.com> (raw)
In-Reply-To: <20070405101933.GA25259@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
Hi again,
The tests in java.util.GregorianCalendar.dayOfWeekInMonth check that
DAY_OF_WEEK_IN_MONTH and WEEK_OF_MONTH are correct when you set dates
using YEAR + MONTH + DAY_OF_MONTH. This commit adds checks in the
opposite direction, ie that DAY_OF_MONTH is correct when you set dates
using YEAR + MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK and using
YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK.
Cheers,
Gary
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 3350 bytes --]
Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.2047
diff -u -r1.2047 ChangeLog
--- ChangeLog 5 Apr 2007 10:18:35 -0000 1.2047
+++ ChangeLog 5 Apr 2007 13:27:14 -0000
@@ -1,3 +1,8 @@
+2007-04-05 Gary Benson <gbenson@redhat.com>
+
+ * gnu/testlet/java/util/GregorianCalendar/dayOfWeekInMonth.java:
+ Test in the opposite direction too.
+
2007-04-05 Gary Benson <gbenson@redhat.com>
* gnu/testlet/java/util/GregorianCalendar/first.java:
Index: gnu/testlet/java/util/GregorianCalendar/dayOfWeekInMonth.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/GregorianCalendar/dayOfWeekInMonth.java,v
retrieving revision 1.1
diff -u -r1.1 dayOfWeekInMonth.java
--- gnu/testlet/java/util/GregorianCalendar/dayOfWeekInMonth.java 5 Apr 2007 10:18:35 -0000 1.1
+++ gnu/testlet/java/util/GregorianCalendar/dayOfWeekInMonth.java 5 Apr 2007 13:27:14 -0000
@@ -34,6 +34,8 @@
public void test(TestHarness harness)
{
GregorianCalendar c = new GregorianCalendar();
+ GregorianCalendar d = new GregorianCalendar();
+ GregorianCalendar e = new GregorianCalendar();
// 31 day months whose first days are the specified weekdays
int testMonths[][] =
@@ -49,11 +51,15 @@
minimalDaysInFirstWeek <= 7; minimalDaysInFirstWeek++) {
c.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
+ d.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
+ e.setMinimalDaysInFirstWeek(minimalDaysInFirstWeek);
for (int firstDayOfWeek = Calendar.SUNDAY;
firstDayOfWeek <= Calendar.SATURDAY; firstDayOfWeek++) {
c.setFirstDayOfWeek(firstDayOfWeek);
+ d.setFirstDayOfWeek(firstDayOfWeek);
+ e.setFirstDayOfWeek(firstDayOfWeek);
for (int i = 0; i < testMonths.length; i++) {
int month = testMonths[i][0];
@@ -61,8 +67,14 @@
int first = testMonths[i][2];
for (int day = 1; day <= 31; day++) {
+ // First we set YEAR + MONTH + DAY_OF_MONTH and check we
+ // have DAY_OF_WEEK_IN_MONTH and WEEK_OF_MONTH correct.
+
c.set(year, month, day);
- harness.check(c.get(Calendar.DAY_OF_WEEK_IN_MONTH) == (day+6) / 7);
+ int dayOfWeekInMonth = (day + 6) / 7;
+
+ harness.check(
+ c.get(Calendar.DAY_OF_WEEK_IN_MONTH) == dayOfWeekInMonth);
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
if (day == 1)
@@ -85,6 +97,26 @@
(day + relativeDayOfFirst - 1) / 7 + weekOfFirst;
harness.check(c.get(Calendar.WEEK_OF_MONTH) == weekOfMonth);
+
+ // Then we set YEAR + MONTH + DAY_OF_WEEK_IN_MONTH +
+ // DAY_OF_WEEK and check we have DAY_OF_MONTH correct.
+
+ d.clear();
+ d.set(Calendar.YEAR, year);
+ d.set(Calendar.MONTH, month);
+ d.set(Calendar.DAY_OF_WEEK_IN_MONTH, dayOfWeekInMonth);
+ d.set(Calendar.DAY_OF_WEEK, dayOfWeek);
+ harness.check(d.get(Calendar.DAY_OF_MONTH) == day);
+
+ // Finally we set YEAR + MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
+ // and check we have DAY_OF_MONTH correct.
+
+ e.clear();
+ e.set(Calendar.YEAR, year);
+ e.set(Calendar.MONTH, month);
+ e.set(Calendar.WEEK_OF_MONTH, weekOfMonth);
+ e.set(Calendar.DAY_OF_WEEK, dayOfWeek);
+ harness.check(e.get(Calendar.DAY_OF_MONTH) == day);
}
}
}
prev parent reply other threads:[~2007-04-05 13:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-05 10:19 FYI: " Gary Benson
2007-04-05 13:32 ` Gary Benson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070405133156.GD25259@redhat.com \
--to=gbenson@redhat.com \
--cc=mauve-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).