Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@ -3,6 +3,7 @@
// (C) 2002 Ulrich Kunitz
//
using System.Collections.Generic;
using NUnit.Framework;
using System;
using System.Globalization;
@ -797,6 +798,44 @@ public class CalendarTest {
Assert.AreEqual (4363, kc.ToFourDigitYear (4363), "#4-4");
}
public void TestDaysInYear (Calendar calendar, int year)
{
var daysInYear = calendar.GetDaysInYear (year);
var daysInMonths = 0;
var monthInYear = calendar.GetMonthsInYear (year);
for (var m = 1; m <= monthInYear; m++)
daysInMonths += calendar.GetDaysInMonth (year, m);
Assert.AreEqual (daysInYear, daysInMonths, string.Format("Calendar:{0} Year:{1}",calendar.GetType(), year));
}
[Test]
public void DaysInYear ()
{
var calendars = new List<Calendar> (acal) {
new UmAlQuraCalendar ()
};
foreach (var calendar in calendars) {
var minYear = calendar.GetYear (calendar.MinSupportedDateTime);
var maxYear = calendar.GetYear (calendar.MaxSupportedDateTime) - 1 ;
var midYear = calendar.GetYear (DateTime.Now);
var yearsTested = Math.Min (1000, (maxYear - minYear) / 2);
midYear -= yearsTested / 2;
int y1 = minYear, y2 = maxYear, y3 = midYear;
for (var i = 0; i < yearsTested; i++) {
TestDaysInYear (calendar, y1);
TestDaysInYear (calendar, y2);
if (y3 > minYear && y3 < maxYear)
TestDaysInYear (calendar, y3);
y1++; y2--; y3++;
}
}
}
// TODO: more tests :-)
} // class CalendarTest