From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25310 invoked by alias); 5 Apr 2007 13:32:13 -0000 Received: (qmail 25302 invoked by uid 22791); 5 Apr 2007 13:32:11 -0000 X-Spam-Check-By: sourceware.org Received: from gbenson.demon.co.uk (HELO gbenson.demon.co.uk) (80.177.220.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 05 Apr 2007 14:32:00 +0100 Date: Thu, 05 Apr 2007 13:32:00 -0000 From: Gary Benson To: mauve-patches@sources.redhat.com Subject: FYI: More GregorianCalendar day of week in month checks Message-ID: <20070405133156.GD25259@redhat.com> Mail-Followup-To: mauve-patches@sources.redhat.com References: <20070405101933.GA25259@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="7qSK/uQB79J36Y4o" Content-Disposition: inline In-Reply-To: <20070405101933.GA25259@redhat.com> X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2007/txt/msg00019.txt.bz2 --7qSK/uQB79J36Y4o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 412 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 --7qSK/uQB79J36Y4o Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-length: 3350 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 + + * gnu/testlet/java/util/GregorianCalendar/dayOfWeekInMonth.java: + Test in the opposite direction too. + 2007-04-05 Gary Benson * 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); } } } --7qSK/uQB79J36Y4o--