20#include <boost/test/unit_test.hpp>
21#include <ql/time/calendar.hpp>
22#include <ql/time/calendars/austria.hpp>
23#include <ql/time/calendars/thailand.hpp>
24#include <ql/time/calendars/chile.hpp>
41using namespace boost::unit_test_framework;
46void checkCalendars(
const std::vector<Date>& expectedHolidays,
const std::vector<Date>& testHolidays) {
48 for (Size i = 0; i < expectedHolidays.size(); i++) {
49 if (testHolidays[i] != expectedHolidays[i])
50 BOOST_FAIL(
"expected holiday was " << expectedHolidays[i] <<
" while calculated holiday is "
58BOOST_AUTO_TEST_SUITE(CalendarsTest)
62 BOOST_TEST_MESSAGE(
"Testing Peruvian holiday list");
64 std::vector<Date> expectedHolidays;
66 expectedHolidays.push_back(Date(1, January, 2018));
67 expectedHolidays.push_back(Date(29, March, 2018));
68 expectedHolidays.push_back(Date(30, March, 2018));
69 expectedHolidays.push_back(Date(1, May, 2018));
70 expectedHolidays.push_back(Date(29, June, 2018));
71 expectedHolidays.push_back(Date(27, July, 2018));
72 expectedHolidays.push_back(Date(30, August, 2018));
73 expectedHolidays.push_back(Date(31, August, 2018));
74 expectedHolidays.push_back(Date(8, October, 2018));
75 expectedHolidays.push_back(Date(1, November, 2018));
76 expectedHolidays.push_back(Date(2, November, 2018));
77 expectedHolidays.push_back(Date(25, December, 2018));
81 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
83 BOOST_CHECK(hol.size() == expectedHolidays.size());
90 BOOST_TEST_MESSAGE(
"Testing Colombian holiday list");
92 std::vector<Date> expectedHolidays;
94 expectedHolidays.push_back(Date(1, January, 2018));
95 expectedHolidays.push_back(Date(8, January, 2018));
96 expectedHolidays.push_back(Date(19, March, 2018));
97 expectedHolidays.push_back(Date(29, March, 2018));
98 expectedHolidays.push_back(Date(30, March, 2018));
99 expectedHolidays.push_back(Date(1, May, 2018));
100 expectedHolidays.push_back(Date(14, May, 2018));
101 expectedHolidays.push_back(Date(4, June, 2018));
102 expectedHolidays.push_back(Date(11, June, 2018));
103 expectedHolidays.push_back(Date(2, July, 2018));
104 expectedHolidays.push_back(Date(20, July, 2018));
105 expectedHolidays.push_back(Date(7, August, 2018));
106 expectedHolidays.push_back(Date(20, August, 2018));
107 expectedHolidays.push_back(Date(15, October, 2018));
108 expectedHolidays.push_back(Date(5, November, 2018));
109 expectedHolidays.push_back(Date(12, November, 2018));
110 expectedHolidays.push_back(Date(25, December, 2018));
114 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
116 BOOST_CHECK(hol.size() == expectedHolidays.size());
123 BOOST_TEST_MESSAGE(
"Testing Philippine holiday list");
125 std::vector<Date> expectedHolidays;
127 expectedHolidays.push_back(Date(1, January, 2018));
128 expectedHolidays.push_back(Date(2, January, 2018));
129 expectedHolidays.push_back(Date(29, March, 2018));
130 expectedHolidays.push_back(Date(30, March, 2018));
131 expectedHolidays.push_back(Date(9, April, 2018));
132 expectedHolidays.push_back(Date(1, May, 2018));
133 expectedHolidays.push_back(Date(12, June, 2018));
134 expectedHolidays.push_back(Date(21, August, 2018));
135 expectedHolidays.push_back(Date(27, August, 2018));
136 expectedHolidays.push_back(Date(1, November, 2018));
137 expectedHolidays.push_back(Date(30, November, 2018));
138 expectedHolidays.push_back(Date(25, December, 2018));
139 expectedHolidays.push_back(Date(31, December, 2018));
143 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
150 BOOST_TEST_MESSAGE(
"Testing Thai holiday list");
152 std::vector<Date> expectedHolidays;
154 expectedHolidays.push_back(Date(1, January, 2018));
155 expectedHolidays.push_back(Date(2, January, 2018));
156 expectedHolidays.push_back(Date(1, March, 2018));
157 expectedHolidays.push_back(Date(6, April, 2018));
158 expectedHolidays.push_back(Date(13, April, 2018));
159 expectedHolidays.push_back(Date(16, April, 2018));
160 expectedHolidays.push_back(Date(1, May, 2018));
161 expectedHolidays.push_back(Date(29, May, 2018));
162 expectedHolidays.push_back(Date(27, July, 2018));
163 expectedHolidays.push_back(Date(30, July, 2018));
164 expectedHolidays.push_back(Date(13, August, 2018));
165 expectedHolidays.push_back(Date(15, October, 2018));
166 expectedHolidays.push_back(Date(23, October, 2018));
167 expectedHolidays.push_back(Date(5, December, 2018));
168 expectedHolidays.push_back(Date(10, December, 2018));
169 expectedHolidays.push_back(Date(31, December, 2018));
171 Calendar c = Thailand();
173 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
175 BOOST_CHECK(hol.size() == expectedHolidays.size());
182 BOOST_TEST_MESSAGE(
"Testing Malaysian holiday list");
184 std::vector<Date> expectedHolidays;
186 expectedHolidays.push_back(Date(1, January, 2018));
187 expectedHolidays.push_back(Date(1, February, 2018));
188 expectedHolidays.push_back(Date(1, May, 2018));
189 expectedHolidays.push_back(Date(31, August, 2018));
190 expectedHolidays.push_back(Date(17, September, 2018));
191 expectedHolidays.push_back(Date(25, December, 2018));
195 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
197 BOOST_CHECK(hol.size() == expectedHolidays.size());
204 BOOST_TEST_MESSAGE(
"Testing Chilean holiday list");
206 std::vector<Date> expectedHolidays;
208 expectedHolidays.push_back(Date(1, January, 2018));
209 expectedHolidays.push_back(Date(30, March, 2018));
210 expectedHolidays.push_back(Date(1, May, 2018));
211 expectedHolidays.push_back(Date(21, May, 2018));
212 expectedHolidays.push_back(Date(2, July, 2018));
213 expectedHolidays.push_back(Date(16, July, 2018));
214 expectedHolidays.push_back(Date(15, August, 2018));
215 expectedHolidays.push_back(Date(17, September, 2018));
216 expectedHolidays.push_back(Date(18, September, 2018));
217 expectedHolidays.push_back(Date(19, September, 2018));
218 expectedHolidays.push_back(Date(15, October, 2018));
219 expectedHolidays.push_back(Date(1, November, 2018));
220 expectedHolidays.push_back(Date(2, November, 2018));
221 expectedHolidays.push_back(Date(25, December, 2018));
223 Calendar c = Chile();
225 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
227 BOOST_CHECK(hol.size() == expectedHolidays.size());
234 BOOST_TEST_MESSAGE(
"Testing Netherlandian holiday list");
236 std::vector<Date> expectedHolidays;
238 expectedHolidays.push_back(Date(1, January, 2018));
239 expectedHolidays.push_back(Date(30, March, 2018));
240 expectedHolidays.push_back(Date(2, April, 2018));
241 expectedHolidays.push_back(Date(27, April, 2018));
242 expectedHolidays.push_back(Date(10, May, 2018));
243 expectedHolidays.push_back(Date(21, May, 2018));
244 expectedHolidays.push_back(Date(25, December, 2018));
245 expectedHolidays.push_back(Date(26, December, 2018));
249 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
251 BOOST_CHECK(hol.size() == expectedHolidays.size());
258 BOOST_TEST_MESSAGE(
"Testing French holiday list");
260 std::vector<Date> expectedHolidays;
262 expectedHolidays.push_back(Date(1, January, 2018));
263 expectedHolidays.push_back(Date(30, March, 2018));
264 expectedHolidays.push_back(Date(2, April, 2018));
265 expectedHolidays.push_back(Date(1, May, 2018));
266 expectedHolidays.push_back(Date(8, May, 2018));
267 expectedHolidays.push_back(Date(10, May, 2018));
268 expectedHolidays.push_back(Date(21, May, 2018));
269 expectedHolidays.push_back(Date(15, August, 2018));
270 expectedHolidays.push_back(Date(1, November, 2018));
271 expectedHolidays.push_back(Date(25, December, 2018));
272 expectedHolidays.push_back(Date(26, December, 2018));
276 std::vector<Date> hol = c.holidayList(Date(1, January, 2018), Date(31, December, 2018));
278 BOOST_CHECK(hol.size() == expectedHolidays.size());
285 BOOST_TEST_MESSAGE(
"Testing Israel Telbor standard weekends");
289 BOOST_CHECK(!c.isWeekend(Friday));
290 BOOST_CHECK(c.isWeekend(Saturday));
291 BOOST_CHECK(c.isWeekend(Sunday));
296 BOOST_TEST_MESSAGE(
"Testing Israel TelAviv weekends");
300 BOOST_CHECK(c.isWeekend(Friday));
301 BOOST_CHECK(c.isWeekend(Saturday));
302 BOOST_CHECK(!c.isWeekend(Sunday));
307 BOOST_TEST_MESSAGE(
"Testing Austrian holiday list");
309 std::vector<Date> expectedHolidays;
311 expectedHolidays.push_back(Date(1, January, 2020));
312 expectedHolidays.push_back(Date(6, January, 2020));
313 expectedHolidays.push_back(Date(13, April, 2020));
314 expectedHolidays.push_back(Date(1, May, 2020));
315 expectedHolidays.push_back(Date(21, May, 2020));
316 expectedHolidays.push_back(Date(1, June, 2020));
317 expectedHolidays.push_back(Date(11, June, 2020));
319 expectedHolidays.push_back(Date(26, October, 2020));
321 expectedHolidays.push_back(Date(8, December, 2020));
322 expectedHolidays.push_back(Date(25, December, 2020));
327 std::vector<Date> hol = c.holidayList(Date(1, January, 2020), Date(31, December, 2020));
329 BOOST_CHECK(hol.size() == expectedHolidays.size());
336 BOOST_TEST_MESSAGE(
"Testing Spanish holiday list");
338 std::vector<Date> expectedHolidays;
340 expectedHolidays.push_back(Date(1, January, 2020));
341 expectedHolidays.push_back(Date(6, January, 2020));
342 expectedHolidays.push_back(Date(10, April, 2020));
343 expectedHolidays.push_back(Date(1, May, 2020));
345 expectedHolidays.push_back(Date(12, October, 2020));
348 expectedHolidays.push_back(Date(8, December, 2020));
349 expectedHolidays.push_back(Date(25, December, 2020));
351 Calendar c =
Spain();
353 std::vector<Date> hol = c.holidayList(Date(1, January, 2020), Date(31, December, 2020));
355 BOOST_CHECK(hol.size() == expectedHolidays.size());
362 BOOST_TEST_MESSAGE(
"Testing Luxembourgian holiday list");
364 std::vector<Date> expectedHolidays;
366 expectedHolidays.push_back(Date(1, January, 2020));
367 expectedHolidays.push_back(Date(13, April, 2020));
368 expectedHolidays.push_back(Date(1, May, 2020));
370 expectedHolidays.push_back(Date(21, May, 2020));
371 expectedHolidays.push_back(Date(1, June, 2020));
372 expectedHolidays.push_back(Date(23, June, 2020));
375 expectedHolidays.push_back(Date(25, December, 2020));
380 std::vector<Date> hol = c.holidayList(Date(1, January, 2020), Date(31, December, 2020));
382 BOOST_CHECK(hol.size() == expectedHolidays.size());
389 BOOST_TEST_MESSAGE(
"Testing Belgian holiday list");
391 std::vector<Date> expectedHolidays;
393 expectedHolidays.push_back(Date(1, January, 2020));
395 expectedHolidays.push_back(Date(13, April, 2020));
396 expectedHolidays.push_back(Date(1, May, 2020));
397 expectedHolidays.push_back(Date(21, May, 2020));
399 expectedHolidays.push_back(Date(1, June, 2020));
400 expectedHolidays.push_back(Date(21, July, 2020));
403 expectedHolidays.push_back(Date(11, November, 2020));
404 expectedHolidays.push_back(Date(25, December, 2020));
408 std::vector<Date> hol = c.holidayList(Date(1, January, 2020), Date(31, December, 2020));
410 BOOST_CHECK(hol.size() == expectedHolidays.size());
417 BOOST_TEST_MESSAGE(
"Testing Cyprus holiday list");
419 std::vector<Date> expectedHolidays;
422 expectedHolidays.push_back(Date(6, January, 2022));
423 expectedHolidays.push_back(Date(7, March, 2022));
424 expectedHolidays.push_back(Date(25, March, 2022));
425 expectedHolidays.push_back(Date(1, April, 2022));
426 expectedHolidays.push_back(Date(22, April, 2022));
427 expectedHolidays.push_back(Date(25, April, 2022));
428 expectedHolidays.push_back(Date(26, April, 2022));
430 expectedHolidays.push_back(Date(13, June, 2022));
431 expectedHolidays.push_back(Date(15, August, 2022));
433 expectedHolidays.push_back(Date(28, October, 2022));
435 expectedHolidays.push_back(Date(26, December, 2022));
439 std::vector<Date> hol = c.holidayList(Date(1, January, 2022), Date(31, December, 2022));
441 BOOST_CHECK(hol.size() == expectedHolidays.size());
448 BOOST_TEST_MESSAGE(
"Testing Greece holiday list");
450 std::vector<Date> expectedHolidays;
452 expectedHolidays.push_back(Date(1, January, 2021));
453 expectedHolidays.push_back(Date(6, January, 2021));
454 expectedHolidays.push_back(Date(15, March, 2021));
455 expectedHolidays.push_back(Date(25, March, 2021));
456 expectedHolidays.push_back(Date(30, April, 2021));
457 expectedHolidays.push_back(Date(3, May, 2021));
458 expectedHolidays.push_back(Date(4, May, 2021));
459 expectedHolidays.push_back(Date(21, June, 2021));
460 expectedHolidays.push_back(Date(28, October, 2021));
462 expectedHolidays.push_back(Date(6, January, 2022));
463 expectedHolidays.push_back(Date(7, March, 2022));
464 expectedHolidays.push_back(Date(25, March, 2022));
465 expectedHolidays.push_back(Date(22, April, 2022));
466 expectedHolidays.push_back(Date(25, April, 2022));
467 expectedHolidays.push_back(Date(13, June, 2022));
468 expectedHolidays.push_back(Date(15, August, 2022));
469 expectedHolidays.push_back(Date(28, October, 2022));
470 expectedHolidays.push_back(Date(26, December, 2022));
476 std::vector<Date> hol = c.holidayList(Date(1, January, 2021), Date(31, December, 2022));
478 BOOST_CHECK(hol.size() == expectedHolidays.size());
485 BOOST_TEST_MESSAGE(
"Testing Irish Stock Exchange holiday list");
487 std::vector<Date> expectedHolidays;
489 expectedHolidays.push_back(Date(1, January, 2021));
490 expectedHolidays.push_back(Date(17, March, 2021));
491 expectedHolidays.push_back(Date(2, April, 2021));
492 expectedHolidays.push_back(Date(5, April, 2021));
493 expectedHolidays.push_back(Date(3, May, 2021));
494 expectedHolidays.push_back(Date(7, June, 2021));
495 expectedHolidays.push_back(Date(2, August, 2021));
496 expectedHolidays.push_back(Date(25, October, 2021));
499 expectedHolidays.push_back(Date(27, December, 2021));
500 expectedHolidays.push_back(Date(28, December, 2021));
504 std::vector<Date> hol = c.holidayList(Date(1, January, 2021), Date(31, December, 2021));
506 BOOST_CHECK(hol.size() == expectedHolidays.size());
513 BOOST_TEST_MESSAGE(
"Testing Irish bank holiday list");
515 std::vector<Date> expectedHolidays;
517 expectedHolidays.push_back(Date(1, January, 2021));
518 expectedHolidays.push_back(Date(17, March, 2021));
519 expectedHolidays.push_back(Date(2, April, 2021));
520 expectedHolidays.push_back(Date(5, April, 2021));
521 expectedHolidays.push_back(Date(3, May, 2021));
522 expectedHolidays.push_back(Date(7, June, 2021));
523 expectedHolidays.push_back(Date(2, August, 2021));
524 expectedHolidays.push_back(Date(25, October, 2021));
527 expectedHolidays.push_back(Date(27, December, 2021));
528 expectedHolidays.push_back(Date(28, December, 2021));
529 expectedHolidays.push_back(Date(29, December, 2021));
533 std::vector<Date> hol = c.holidayList(Date(1, January, 2021), Date(31, December, 2021));
535 BOOST_CHECK(hol.size() == expectedHolidays.size());
541BOOST_AUTO_TEST_SUITE_END()
543BOOST_AUTO_TEST_SUITE_END()
Israel calendar extension to cover TELBOR publication days.
void checkCalendars(const std::vector< Date > &expectedHolidays, const std::vector< Date > &testHolidays)
BOOST_AUTO_TEST_CASE(testPeruvianCalendar)
Fixture that can be used at top level.