package name.abuchen.portfolio.util;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.time.LocalDate;
import java.time.Month;

import org.junit.Test;

public class DatesTest
{
    @Test
    public void testSame()
    {
        LocalDate d1 = LocalDate.of(2010, Month.JANUARY, 1);
        assertThat(Dates.daysBetween(d1, d1), is(0));
    }

    @Test
    public void testOne()
    {
        LocalDate d1 = LocalDate.of(2010, Month.JANUARY, 1);
        LocalDate d2 = LocalDate.of(2010, Month.JANUARY, 2);
        assertThat(Dates.daysBetween(d1, d2), is(1));
    }

    @Test
    public void testYearLeap()
    {
        LocalDate d1 = LocalDate.of(2009, Month.DECEMBER, 31);
        LocalDate d2 = LocalDate.of(2010, Month.JANUARY, 1);
        assertThat(Dates.daysBetween(d1, d2), is(1));
    }

    @Test
    public void testReverse()
    {
        LocalDate d1 = LocalDate.of(2009, Month.DECEMBER, 31);
        LocalDate d2 = LocalDate.of(2010, Month.JANUARY, 1);
        assertThat(Dates.daysBetween(d2, d1), is(1));
    }

    @Test
    public void testLeapYear()
    {
        LocalDate d1 = LocalDate.of(2008, Month.FEBRUARY, 28);
        LocalDate d2 = LocalDate.of(2008, Month.MARCH, 1);
        assertThat(Dates.daysBetween(d1, d2), is(2));
    }

}

@@ -1298,11 +1298,1453 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void testTradingDaysSame()%0A    %7B%0A        LocalDate d1 = LocalDate.of(2020, Month.MARCH, 16);%0A        assertThat(Dates.tradingDaysBetween(d1, d1), is(0));%0A    %7D%0A    %0A    @Test%0A    public void testTradingDaysOne()%0A    %7B%0A        LocalDate d1 = LocalDate.of(2020, Month.MARCH, 16);%0A        LocalDate d2 = LocalDate.of(2020, Month.MARCH, 17);%0A        assertThat(Dates.tradingDaysBetween(d1, d2), is(1));%0A    %7D%0A    %0A    @Test%0A    public void testTradingDaysReverse()%0A    %7B%0A        LocalDate d1 = LocalDate.of(2020, Month.MARCH, 16);%0A        LocalDate d2 = LocalDate.of(2020, Month.MARCH, 17);%0A        assertThat(Dates.tradingDaysBetween(d2, d1), is(1));%0A    %7D%0A    %0A    @Test%0A    public void testTradingDaysWeek()%0A    %7B%0A        LocalDate d1 = LocalDate.of(2020, Month.MARCH, 15); // Sunday%0A        LocalDate d2 = LocalDate.of(2020, Month.MARCH, 21); // Saturday%0A        assertThat(Dates.tradingDaysBetween(d2, d1), is(5));%0A        %0A        LocalDate d3 = LocalDate.of(2020, Month.MARCH, 15); // Sunday%0A        LocalDate d4 = LocalDate.of(2020, Month.MARCH, 22); // Sunday%0A        assertThat(Dates.tradingDaysBetween(d3, d4), is(5));%0A    %7D%0A    %0A    @Test%0A    public void testTradingDaysWeekPublicHoliday()%0A    %7B%0A        LocalDate d1 = LocalDate.of(2020, Month.APRIL, 9); // Thursday%0A        LocalDate d2 = LocalDate.of(2020, Month.APRIL, 10); // Good Friday%0A        assertThat(Dates.tradingDaysBetween(d2, d1), is(0));%0A    %7D
 %0A%7D%0A

Test for tradingDaysBetween function