mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-18 09:30:13 +08:00
Test only one wxDateTimeHolidayAuthority at a time
wxDateTimeChristianHolidays was tested with a wxDateTimeUSCatholicFeasts already existing and taking precedence. I.e. the tests for Christmas in ChristianHolidays actually tested (again) the USCatholicFeasts implementation. This reveals an off-by-one bug in wxDateTimeChristianHolidays::DoIsHoliday(), which doesn't use the enum symbol for month, and declares Christmas to be on the 25th day of the 13th month. Further, this raises the question whether it is a bad idea to have the authority implementations in a header. Fixing bugs like this would require recompiling the application, instead of simply updating the DLL/dylib.
This commit is contained in:
committed by
Vadim Zeitlin
parent
ab967cac5b
commit
9bbb2dfb6b
@@ -21,6 +21,7 @@
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/wxcrt.h" // for wxStrstr()
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
#include "wx/private/localeset.h"
|
||||
|
||||
@@ -2538,6 +2539,12 @@ TEST_CASE("Easter", "[datetime][holiday][easter]")
|
||||
|
||||
TEST_CASE("US Catholic Holidays", "[datetime][holiday]")
|
||||
{
|
||||
// Clear the wxDateTimeWorkDays that exists by default, and restore it at the end,
|
||||
// after cleaning up the authority tested here.
|
||||
wxDateTimeHolidayAuthority::ClearAllAuthorities();
|
||||
wxON_BLOCK_EXIT0(wxDateTimeHolidayAuthority::ClearAllAuthorities);
|
||||
wxON_BLOCK_EXIT1(wxDateTimeHolidayAuthority::AddAuthority, new wxDateTimeWorkDays);
|
||||
|
||||
SECTION("Ascension")
|
||||
{
|
||||
wxDateTime ascension = wxDateTimeUSCatholicFeasts::GetThursdayAscension(2023);
|
||||
@@ -2565,6 +2572,12 @@ TEST_CASE("US Catholic Holidays", "[datetime][holiday]")
|
||||
|
||||
TEST_CASE("Christian Holidays", "[datetime][holiday][christian]")
|
||||
{
|
||||
// Clear the wxDateTimeWorkDays that exists by default, and restore it at the end,
|
||||
// after cleaning up the authority tested here.
|
||||
wxDateTimeHolidayAuthority::ClearAllAuthorities();
|
||||
wxON_BLOCK_EXIT0(wxDateTimeHolidayAuthority::ClearAllAuthorities);
|
||||
wxON_BLOCK_EXIT1(wxDateTimeHolidayAuthority::AddAuthority, new wxDateTimeWorkDays);
|
||||
|
||||
SECTION("Easter")
|
||||
{
|
||||
wxDateTime easter = wxDateTimeChristianHolidays::GetEaster(2023);
|
||||
|
||||
Reference in New Issue
Block a user