package net.time4j;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;


@RunWith(JUnit4.class)
public class MonthValueTest {

    @Test
    public void valueOf_int() {
        for (int i = 0; i < 12; i++) {
            assertThat(Month.valueOf(i + 1), is(Month.values()[i]));
        }
    }

    @Test
    public void getValue() {
        for (int i = 0; i < 12; i++) {
            assertThat(Month.values()[i].getValue(), is(i + 1));
        }
    }

    @Test
    public void getQuarterOfYear() {
        assertThat(Month.JANUARY.getQuarterOfYear(), is(Quarter.Q1));
        assertThat(Month.FEBRUARY.getQuarterOfYear(), is(Quarter.Q1));
        assertThat(Month.MARCH.getQuarterOfYear(), is(Quarter.Q1));
        assertThat(Month.APRIL.getQuarterOfYear(), is(Quarter.Q2));
        assertThat(Month.MAY.getQuarterOfYear(), is(Quarter.Q2));
        assertThat(Month.JUNE.getQuarterOfYear(), is(Quarter.Q2));
        assertThat(Month.JULY.getQuarterOfYear(), is(Quarter.Q3));
        assertThat(Month.AUGUST.getQuarterOfYear(), is(Quarter.Q3));
        assertThat(Month.SEPTEMBER.getQuarterOfYear(), is(Quarter.Q3));
        assertThat(Month.OCTOBER.getQuarterOfYear(), is(Quarter.Q4));
        assertThat(Month.NOVEMBER.getQuarterOfYear(), is(Quarter.Q4));
        assertThat(Month.DECEMBER.getQuarterOfYear(), is(Quarter.Q4));
    }

    @Test
    public void getLength() {
        assertThat(Month.JANUARY.getLength(2012), is(31));
        assertThat(Month.FEBRUARY.getLength(2012), is(29));
        assertThat(Month.FEBRUARY.getLength(1900), is(28));
        assertThat(Month.MARCH.getLength(2012), is(31));
        assertThat(Month.APRIL.getLength(2012), is(30));
        assertThat(Month.MAY.getLength(2012), is(31));
        assertThat(Month.JUNE.getLength(2012), is(30));
        assertThat(Month.JULY.getLength(2012), is(31));
        assertThat(Month.AUGUST.getLength(2012), is(31));
        assertThat(Month.SEPTEMBER.getLength(2012), is(30));
        assertThat(Month.OCTOBER.getLength(2012), is(31));
        assertThat(Month.NOVEMBER.getLength(2012), is(30));
        assertThat(Month.DECEMBER.getLength(2012), is(31));
    }

    @Test
    public void next() {
        assertThat(Month.FEBRUARY.next(), is(Month.MARCH));
        assertThat(Month.DECEMBER.next(), is(Month.JANUARY));
    }

    @Test
    public void previous() {
        assertThat(Month.FEBRUARY.previous(), is(Month.JANUARY));
        assertThat(Month.JANUARY.previous(), is(Month.DECEMBER));
    }

    @Test
    public void roll() {
        assertThat(Month.FEBRUARY.roll(-2), is(Month.DECEMBER));
    }

    @Test
    public void test() {
        assertThat(Month.FEBRUARY.test(PlainDate.of(2012, 2, 17)), is(true));
    }

    @Test
    public void atStartOfQuarterYear() {
        assertThat(Month.atStartOfQuarterYear(Quarter.Q1), is(Month.JANUARY));
        assertThat(Month.atStartOfQuarterYear(Quarter.Q2), is(Month.APRIL));
        assertThat(Month.atStartOfQuarterYear(Quarter.Q3), is(Month.JULY));
        assertThat(Month.atStartOfQuarterYear(Quarter.Q4), is(Month.OCTOBER));
    }

    @Test
    public void atEndOfQuarterYear() {
        assertThat(Month.atEndOfQuarterYear(Quarter.Q1), is(Month.MARCH));
        assertThat(Month.atEndOfQuarterYear(Quarter.Q2), is(Month.JUNE));
        assertThat(Month.atEndOfQuarterYear(Quarter.Q3), is(Month.SEPTEMBER));
        assertThat(Month.atEndOfQuarterYear(Quarter.Q4), is(Month.DECEMBER));
    }

}
@@ -15,16 +15,92 @@
 me4j;%0A%0A%0A
+import net.time4j.format.OutputContext;%0Aimport net.time4j.format.TextWidth;%0A
 import o
@@ -181,16 +181,42 @@
 Unit4;%0A%0A
+import java.util.Locale;%0A%0A
 import s
@@ -3666,9 +3666,449 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void czechMonthInFormatContext() %7B%0A        assertThat(%0A            Month.JANUARY.getDisplayName(new Locale(%22cs%22), TextWidth.WIDE, OutputContext.FORMAT),%0A            is(%22ledna%22)%0A        );%0A    %7D%0A%0A    @Test%0A    public void czechMonthInStandaloneContext() %7B%0A        assertThat(%0A            Month.JANUARY.getDisplayName(new Locale(%22cs%22), TextWidth.WIDE, OutputContext.STANDALONE),%0A            is(%22leden%22)%0A        );%0A    %7D%0A%0A
 %7D

test for JDK-standalone support