tests/libjava-mauve/src/gnu/testlet/java/util/GregorianCalendar/setWeekOfMonth.java
branchjk_new_structure
changeset 1541 75c2e24dea9a
parent 1540 92ac284961c1
child 1542 be11db817bcf
equal deleted inserted replaced
1540:92ac284961c1 1541:75c2e24dea9a
     1 // Tags: JDK1.1
       
     2 
       
     3 // Copyright (C) 2006 Mark J. Wielaard (mark@klomp.org)
       
     4 
       
     5 // This file is part of Mauve.
       
     6 
       
     7 // Mauve is free software; you can redistribute it and/or modify
       
     8 // it under the terms of the GNU General Public License as published by
       
     9 // the Free Software Foundation; either version 2, or (at your option)
       
    10 // any later version.
       
    11 
       
    12 // Mauve is distributed in the hope that it will be useful,
       
    13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15 // GNU General Public License for more details.
       
    16 
       
    17 // You should have received a copy of the GNU General Public License
       
    18 // along with Mauve; see the file COPYING.  If not, write to
       
    19 // the Free Software Foundation, 59 Temple Place - Suite 330,
       
    20 // Boston, MA 02111-1307, USA.
       
    21 
       
    22 
       
    23 package gnu.testlet.java.util.GregorianCalendar;
       
    24 
       
    25 import gnu.testlet.Testlet;
       
    26 import gnu.testlet.TestHarness;
       
    27 
       
    28 import java.util.Calendar;
       
    29 import java.util.GregorianCalendar;
       
    30 import java.util.Locale;
       
    31 import java.util.TimeZone;
       
    32 
       
    33 public class setWeekOfMonth
       
    34   implements Testlet
       
    35 {
       
    36   public void test(TestHarness harness)
       
    37   {
       
    38     GregorianCalendar cal;
       
    39     cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.US);
       
    40 
       
    41     // Month with 6 weeks
       
    42     cal.set(2006, Calendar.JULY, 30);
       
    43     cal.setLenient(false);
       
    44 
       
    45     harness.check(cal.getMaximum(Calendar.WEEK_OF_MONTH), 6);
       
    46 
       
    47     cal.clear(Calendar.DAY_OF_MONTH);
       
    48     cal.set(Calendar.WEEK_OF_MONTH, 1);
       
    49     cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
       
    50     harness.check(cal.get(Calendar.DAY_OF_MONTH), 1);
       
    51 
       
    52     cal.clear(Calendar.DAY_OF_MONTH);
       
    53     cal.set(Calendar.WEEK_OF_MONTH, 6);
       
    54     cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
       
    55     harness.check(cal.get(Calendar.DAY_OF_MONTH), 31);
       
    56 
       
    57     // Month with 4 weeks
       
    58     cal.set(1998, Calendar.FEBRUARY, 14);
       
    59     cal.clear(Calendar.DAY_OF_MONTH);
       
    60     cal.set(Calendar.WEEK_OF_MONTH, 1);
       
    61     cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
       
    62     harness.check(cal.get(Calendar.DAY_OF_MONTH), 1);
       
    63     
       
    64     cal.clear(Calendar.DAY_OF_MONTH);
       
    65     cal.set(Calendar.WEEK_OF_MONTH, 4);
       
    66     cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
       
    67     harness.check(cal.get(Calendar.DAY_OF_MONTH), 28);
       
    68     harness.check(cal.get(Calendar.MONTH), Calendar.FEBRUARY);
       
    69 
       
    70     // Month with 5 weeks
       
    71     cal.set(1993, Calendar.FEBRUARY, 14);
       
    72     cal.clear(Calendar.DAY_OF_MONTH);
       
    73     cal.set(Calendar.WEEK_OF_MONTH, 5);
       
    74     cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
       
    75     harness.check(cal.get(Calendar.DAY_OF_MONTH), 28);
       
    76   }
       
    77 }