1 #undef G_DISABLE_ASSERT
4 /* We are testing some deprecated APIs here */
5 #define GLIB_DISABLE_DEPRECATION_WARNINGS
16 #define WIN32_LEAN_AND_MEAN
23 g_assert_cmpint (sizeof (GDate
), <, 9);
24 g_assert (!g_date_valid_month (G_DATE_BAD_MONTH
));
25 g_assert (!g_date_valid_month (13));
26 g_assert (!g_date_valid_day (G_DATE_BAD_DAY
));
27 g_assert (!g_date_valid_day (32));
28 g_assert (!g_date_valid_year (G_DATE_BAD_YEAR
));
29 g_assert (!g_date_valid_julian (G_DATE_BAD_JULIAN
));
30 g_assert (!g_date_valid_weekday (G_DATE_BAD_WEEKDAY
));
31 g_assert (g_date_is_leap_year (2000));
32 g_assert (!g_date_is_leap_year (1999));
33 g_assert (g_date_is_leap_year (1996));
34 g_assert (g_date_is_leap_year (1600));
35 g_assert (!g_date_is_leap_year (2100));
36 g_assert (!g_date_is_leap_year (1800));
40 test_empty_constructor (void)
45 g_assert (!g_date_valid (d
));
50 test_dmy_constructor (void)
55 d
= g_date_new_dmy (1, 1, 1);
56 g_assert (g_date_valid (d
));
57 j
= g_date_get_julian (d
);
58 g_assert_cmpint (j
, ==, 1);
59 g_assert_cmpint (g_date_get_month (d
), ==, G_DATE_JANUARY
);
60 g_assert_cmpint (g_date_get_day (d
), ==, 1);
61 g_assert_cmpint (g_date_get_year (d
), ==, 1);
66 test_julian_constructor (void)
71 d1
= g_date_new_julian (4000);
72 d2
= g_date_new_julian (5000);
73 g_assert_cmpint (g_date_get_julian (d1
), ==, 4000);
74 g_assert_cmpint (g_date_days_between (d1
, d2
), ==, 1000);
75 g_assert_cmpint (g_date_get_year (d1
), ==, 11);
76 g_assert_cmpint (g_date_get_day (d2
), ==, 9);
90 g_date_set_time (d
, time (NULL
));
91 g_assert (g_date_valid (d
));
94 g_date_set_time (d
, 1);
95 g_assert (g_date_valid (d
));
99 g_date_set_time_val (d
, &tv
);
100 g_assert (g_date_valid (d
));
103 g_date_set_julian (d
, 1);
104 g_assert (g_date_valid (d
));
106 g_date_set_year (d
, 3);
107 g_date_set_day (d
, 3);
108 g_date_set_month (d
, 3);
109 g_assert (g_date_valid (d
));
110 g_assert_cmpint (g_date_get_year (d
), ==, 3);
111 g_assert_cmpint (g_date_get_month (d
), ==, 3);
112 g_assert_cmpint (g_date_get_day (d
), ==, 3);
113 g_assert (!g_date_is_first_of_month (d
));
114 g_assert (!g_date_is_last_of_month (d
));
115 g_date_set_day (d
, 1);
116 g_assert (g_date_is_first_of_month (d
));
117 g_date_subtract_days (d
, 1);
118 g_assert (g_date_is_last_of_month (d
));
131 g_date_set_dmy (d
, 10, 1, 2000);
132 g_date_strftime (buf
, 100, "%x", d
);
134 g_date_set_parse (d
, buf
);
135 g_assert (g_date_valid (d
));
136 g_assert_cmpint (g_date_get_month (d
), ==, 1);
137 g_assert_cmpint (g_date_get_day (d
), ==, 10);
138 g_assert_cmpint (g_date_get_year (d
), ==, 2000);
140 g_date_set_parse (d
, "2001 10 1");
141 g_assert (g_date_valid (d
));
142 g_assert_cmpint (g_date_get_month (d
), ==, 10);
143 g_assert_cmpint (g_date_get_day (d
), ==, 1);
144 g_assert_cmpint (g_date_get_year (d
), ==, 2001);
146 g_date_set_parse (d
, "2001 10");
147 g_assert (!g_date_valid (d
));
149 g_date_set_parse (d
, "2001 10 1 1");
150 g_assert (!g_date_valid (d
));
152 g_date_set_parse (d
, "March 1999");
153 g_assert (g_date_valid (d
));
154 g_assert_cmpint (g_date_get_month (d
), ==, 3);
155 g_assert_cmpint (g_date_get_day (d
), ==, 1);
156 g_assert_cmpint (g_date_get_year (d
), ==, 1999);
158 g_date_set_parse (d
, "10 Sep 1087");
159 g_assert (g_date_valid (d
));
160 g_assert_cmpint (g_date_get_month (d
), ==, 9);
161 g_assert_cmpint (g_date_get_day (d
), ==, 10);
162 g_assert_cmpint (g_date_get_year (d
), ==, 1087);
164 g_date_set_parse (d
, "19990301");
165 g_assert (g_date_valid (d
));
166 g_assert_cmpint (g_date_get_month (d
), ==, 3);
167 g_assert_cmpint (g_date_get_day (d
), ==, 1);
168 g_assert_cmpint (g_date_get_year (d
), ==, 1999);
170 g_date_set_parse (d
, "20011320");
171 g_assert (!g_date_valid (d
));
177 test_month_names (void)
179 #if defined(HAVE_LANGINFO_ABALTMON) || defined(G_OS_WIN32)
186 #endif /* defined(HAVE_LANGINFO_ABALTMON) || defined(G_OS_WIN32) */
188 g_test_bug ("749206");
190 /* This test can only work (on non-Windows platforms) if libc supports the %OB
191 * (etc.) format placeholders. If it doesn’t, strftime() (and hence
192 * g_date_strftime()) will return the placeholder unsubstituted.
193 * g_date_strftime() explicitly documents that it doesn’t provide any more
194 * format placeholders than the system strftime(), so we should skip the test
195 * in that case. If people need %OB support, they should depend on a suitable
196 * version of libc, or use g_date_time_format(). */
197 #if !defined(HAVE_LANGINFO_ABALTMON) && !defined(G_OS_WIN32)
198 g_test_skip ("libc doesn’t support alternate month names");
201 #define TEST_DATE(d,m,y,f,o) \
202 g_date_set_dmy (gdate, d, m, y); \
203 g_date_strftime (buf, 100, f, gdate); \
204 g_assert_cmpstr (buf, ==, (o)); \
205 g_date_set_parse (gdate, buf); \
206 g_assert (g_date_valid (gdate)); \
207 g_assert_cmpint (g_date_get_day (gdate), ==, d); \
208 g_assert_cmpint (g_date_get_month (gdate), ==, m); \
209 g_assert_cmpint (g_date_get_year (gdate), ==, y);
211 oldlocale
= g_strdup (setlocale (LC_ALL
, NULL
));
213 old_lcid
= GetThreadLocale ();
216 gdate
= g_date_new ();
218 /* Note: Windows implementation of g_date_strftime() does not support
219 * "-" format modifier (e.g., "%-d", "%-e") so we will not use it.
222 /* Make sure that nothing has been changed in western European languages. */
223 setlocale (LC_ALL
, "en_GB.utf-8");
225 SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH
, SUBLANG_ENGLISH_UK
), SORT_DEFAULT
));
227 if (strstr (setlocale (LC_ALL
, NULL
), "en_GB") != NULL
)
229 TEST_DATE (1, 1, 2018, "%B %d, %Y", "January 01, 2018");
230 TEST_DATE (1, 2, 2018, "%OB %Y", "February 2018");
231 TEST_DATE (1, 3, 2018, "%e %b %Y", " 1 Mar 2018");
232 TEST_DATE (1, 4, 2018, "%Ob %Y", "Apr 2018");
233 TEST_DATE (1, 5, 2018, "%d %h %Y", "01 May 2018");
234 TEST_DATE (1, 6, 2018, "%Oh %Y", "Jun 2018");
237 g_test_incomplete ("locale en_GB not available, skipping English month names test");
239 setlocale (LC_ALL
, "de_DE.utf-8");
241 SetThreadLocale (MAKELCID (MAKELANGID (LANG_GERMAN
, SUBLANG_GERMAN
), SORT_DEFAULT
));
243 if (strstr (setlocale (LC_ALL
, NULL
), "de_DE") != NULL
)
245 TEST_DATE (16, 7, 2018, "%d. %B %Y", "16. Juli 2018");
246 TEST_DATE ( 1, 8, 2018, "%OB %Y", "August 2018");
247 TEST_DATE (18, 9, 2018, "%e. %b %Y", "18. Sep 2018");
248 TEST_DATE ( 1, 10, 2018, "%Ob %Y", "Okt 2018");
249 TEST_DATE (20, 11, 2018, "%d. %h %Y", "20. Nov 2018");
250 TEST_DATE ( 1, 12, 2018, "%Oh %Y", "Dez 2018");
253 g_test_incomplete ("locale de_DE not available, skipping German month names test");
256 setlocale (LC_ALL
, "es_ES.utf-8");
258 SetThreadLocale (MAKELCID (MAKELANGID (LANG_SPANISH
, SUBLANG_SPANISH_MODERN
), SORT_DEFAULT
));
260 if (strstr (setlocale (LC_ALL
, NULL
), "es_ES") != NULL
)
262 TEST_DATE ( 9, 1, 2018, "%d de %B de %Y", "09 de enero de 2018");
263 TEST_DATE ( 1, 2, 2018, "%OB de %Y", "febrero de 2018");
264 TEST_DATE (10, 3, 2018, "%e de %b de %Y", "10 de mar de 2018");
265 TEST_DATE ( 1, 4, 2018, "%Ob de %Y", "abr de 2018");
266 TEST_DATE (11, 5, 2018, "%d de %h de %Y", "11 de may de 2018");
267 TEST_DATE ( 1, 6, 2018, "%Oh de %Y", "jun de 2018");
270 g_test_incomplete ("locale es_ES not available, skipping Spanish month names test");
272 setlocale (LC_ALL
, "fr_FR.utf-8");
274 SetThreadLocale (MAKELCID (MAKELANGID (LANG_FRENCH
, SUBLANG_FRENCH
), SORT_DEFAULT
));
276 if (strstr (setlocale (LC_ALL
, NULL
), "fr_FR") != NULL
)
278 TEST_DATE (31, 7, 2018, "%d %B %Y", "31 juillet 2018");
279 TEST_DATE ( 1, 8, 2018, "%OB %Y", "août 2018");
280 TEST_DATE (30, 9, 2018, "%e %b %Y", "30 sept. 2018");
281 TEST_DATE ( 1, 10, 2018, "%Ob %Y", "oct. 2018");
282 TEST_DATE (29, 11, 2018, "%d %h %Y", "29 nov. 2018");
283 TEST_DATE ( 1, 12, 2018, "%Oh %Y", "déc. 2018");
286 g_test_incomplete ("locale fr_FR not available, skipping French month names test");
288 /* Make sure that there are visible changes in some European languages. */
289 setlocale (LC_ALL
, "el_GR.utf-8");
291 SetThreadLocale (MAKELCID (MAKELANGID (LANG_GREEK
, SUBLANG_GREEK_GREECE
), SORT_DEFAULT
));
293 if (strstr (setlocale (LC_ALL
, NULL
), "el_GR") != NULL
)
295 TEST_DATE ( 2, 1, 2018, "%d %B %Y", "02 Ιανουαρίου 2018");
296 TEST_DATE ( 4, 2, 2018, "%e %B %Y", " 4 Φεβρουαρίου 2018");
297 TEST_DATE (15, 3, 2018, "%d %B %Y", "15 Μαρτίου 2018");
298 TEST_DATE ( 1, 4, 2018, "%OB %Y", "Απρίλιος 2018");
299 TEST_DATE ( 1, 5, 2018, "%OB %Y", "Μάιος 2018");
300 TEST_DATE ( 1, 6, 2018, "%OB %Y", "Ιούνιος 2018");
301 TEST_DATE (16, 7, 2018, "%e %b %Y", "16 Ιούλ 2018");
302 TEST_DATE ( 1, 8, 2018, "%Ob %Y", "Αύγ 2018");
305 g_test_incomplete ("locale el_GR not available, skipping Greek month names test");
307 setlocale (LC_ALL
, "hr_HR.utf-8");
309 SetThreadLocale (MAKELCID (MAKELANGID (LANG_CROATIAN
, SUBLANG_CROATIAN_CROATIA
), SORT_DEFAULT
));
311 if (strstr (setlocale (LC_ALL
, NULL
), "hr_HR") != NULL
)
313 TEST_DATE ( 8, 5, 2018, "%d. %B %Y", "08. svibnja 2018");
314 TEST_DATE ( 9, 6, 2018, "%e. %B %Y", " 9. lipnja 2018");
315 TEST_DATE (10, 7, 2018, "%d. %B %Y", "10. srpnja 2018");
316 TEST_DATE ( 1, 8, 2018, "%OB %Y", "Kolovoz 2018");
317 TEST_DATE ( 1, 9, 2018, "%OB %Y", "Rujan 2018");
318 TEST_DATE ( 1, 10, 2018, "%OB %Y", "Listopad 2018");
319 TEST_DATE (11, 11, 2018, "%e. %b %Y", "11. Stu 2018");
320 TEST_DATE ( 1, 12, 2018, "%Ob %Y", "Pro 2018");
323 g_test_incomplete ("locale hr_HR not available, skipping Croatian month names test");
325 setlocale (LC_ALL
, "lt_LT.utf-8");
327 SetThreadLocale (MAKELCID (MAKELANGID (LANG_LITHUANIAN
, SUBLANG_LITHUANIAN_LITHUANIA
), SORT_DEFAULT
));
329 if (strstr (setlocale (LC_ALL
, NULL
), "lt_LT") != NULL
)
331 TEST_DATE ( 1, 1, 2018, "%Y m. %B %d d.", "2018 m. sausio 01 d.");
332 TEST_DATE ( 2, 2, 2018, "%Y m. %B %e d.", "2018 m. vasario 2 d.");
333 TEST_DATE ( 3, 3, 2018, "%Y m. %B %d d.", "2018 m. kovo 03 d.");
334 TEST_DATE ( 1, 4, 2018, "%Y m. %OB", "2018 m. balandis");
335 TEST_DATE ( 1, 5, 2018, "%Y m. %OB", "2018 m. gegužė");
336 TEST_DATE ( 1, 6, 2018, "%Y m. %OB", "2018 m. birželis");
337 TEST_DATE (17, 7, 2018, "%Y m. %b %e d.", "2018 m. Lie 17 d.");
338 TEST_DATE ( 1, 8, 2018, "%Y m. %Ob", "2018 m. Rgp");
341 g_test_incomplete ("locale lt_LT not available, skipping Lithuanian month names test");
343 setlocale (LC_ALL
, "pl_PL.utf-8");
345 SetThreadLocale (MAKELCID (MAKELANGID (LANG_POLISH
, SUBLANG_POLISH_POLAND
), SORT_DEFAULT
));
347 if (strstr (setlocale (LC_ALL
, NULL
), "pl_PL") != NULL
)
349 TEST_DATE ( 3, 5, 2018, "%d %B %Y", "03 maja 2018");
350 TEST_DATE ( 4, 6, 2018, "%e %B %Y", " 4 czerwca 2018");
351 TEST_DATE (20, 7, 2018, "%d %B %Y", "20 lipca 2018");
352 TEST_DATE ( 1, 8, 2018, "%OB %Y", "sierpień 2018");
353 TEST_DATE ( 1, 9, 2018, "%OB %Y", "wrzesień 2018");
354 TEST_DATE ( 1, 10, 2018, "%OB %Y", "październik 2018");
355 TEST_DATE (25, 11, 2018, "%e %b %Y", "25 lis 2018");
356 TEST_DATE ( 1, 12, 2018, "%Ob %Y", "gru 2018");
359 g_test_incomplete ("locale pl_PL not available, skipping Polish month names test");
361 setlocale (LC_ALL
, "ru_RU.utf-8");
363 SetThreadLocale (MAKELCID (MAKELANGID (LANG_RUSSIAN
, SUBLANG_RUSSIAN_RUSSIA
), SORT_DEFAULT
));
365 if (strstr (setlocale (LC_ALL
, NULL
), "ru_RU") != NULL
)
367 TEST_DATE ( 3, 1, 2018, "%d %B %Y", "03 января 2018");
368 TEST_DATE ( 4, 2, 2018, "%e %B %Y", " 4 февраля 2018");
369 TEST_DATE (23, 3, 2018, "%d %B %Y", "23 марта 2018");
370 TEST_DATE ( 1, 4, 2018, "%OB %Y", "Апрель 2018");
371 TEST_DATE ( 1, 5, 2018, "%OB %Y", "Май 2018");
372 TEST_DATE ( 1, 6, 2018, "%OB %Y", "Июнь 2018");
373 TEST_DATE (24, 7, 2018, "%e %b %Y", "24 июл 2018");
374 TEST_DATE ( 1, 8, 2018, "%Ob %Y", "авг 2018");
375 /* This difference is very important in Russian: */
376 TEST_DATE (19, 5, 2018, "%e %b %Y", "19 мая 2018");
377 TEST_DATE (20, 5, 2018, "%Ob, %d-е, %Y", "май, 20-е, 2018");
380 g_test_incomplete ("locale ru_RU not available, skipping Russian month names test");
384 setlocale (LC_ALL
, oldlocale
);
386 SetThreadLocale (old_lcid
);
389 #endif /* defined(HAVE_LANGINFO_ABALTMON) || defined(G_OS_WIN32) */
393 test_year (gconstpointer t
)
395 GDateYear y
= GPOINTER_TO_INT (t
);
403 guint32 first_day_of_year
= G_DATE_BAD_JULIAN
;
404 guint16 days_in_year
= g_date_is_leap_year (y
) ? 366 : 365;
405 guint sunday_week_of_year
= 0;
406 guint sunday_weeks_in_year
= g_date_get_sunday_weeks_in_year (y
);
407 guint monday_week_of_year
= 0;
408 guint monday_weeks_in_year
= g_date_get_monday_weeks_in_year (y
);
409 guint iso8601_week_of_year
= 0;
411 g_assert (g_date_valid_year (y
));
412 /* Years ought to have roundabout 52 weeks */
413 g_assert (sunday_weeks_in_year
== 52 || sunday_weeks_in_year
== 53);
414 g_assert (monday_weeks_in_year
== 52 || monday_weeks_in_year
== 53);
419 guint8 dim
= g_date_get_days_in_month (m
, y
);
422 g_date_clear (days
, 31);
424 g_assert (dim
> 0 && dim
< 32);
425 g_assert (g_date_valid_month (m
));
430 g_assert (g_date_valid_dmy (day
, m
, y
));
433 //g_assert (!g_date_valid (d));
435 g_date_set_dmy (d
, day
, m
, y
);
437 g_assert (g_date_valid (d
));
439 if (m
== G_DATE_JANUARY
&& day
== 1)
440 first_day_of_year
= g_date_get_julian (d
);
442 g_assert (first_day_of_year
!= G_DATE_BAD_JULIAN
);
444 g_assert_cmpint (g_date_get_month (d
), ==, m
);
445 g_assert_cmpint (g_date_get_year (d
), ==, y
);
446 g_assert_cmpint (g_date_get_day (d
), ==, day
);
448 g_assert (g_date_get_julian (d
) + 1 - first_day_of_year
==
449 g_date_get_day_of_year (d
));
451 if (m
== G_DATE_DECEMBER
&& day
== 31)
452 g_assert_cmpint (g_date_get_day_of_year (d
), ==, days_in_year
);
454 g_assert_cmpint (g_date_get_day_of_year (d
), <=, days_in_year
);
455 g_assert_cmpint (g_date_get_monday_week_of_year (d
), <=, monday_weeks_in_year
);
456 g_assert_cmpint (g_date_get_monday_week_of_year (d
), >=, monday_week_of_year
);
458 if (g_date_get_weekday(d
) == G_DATE_MONDAY
)
460 g_assert_cmpint (g_date_get_monday_week_of_year (d
) - monday_week_of_year
, ==, 1);
461 if ((m
== G_DATE_JANUARY
&& day
<= 4) ||
462 (m
== G_DATE_DECEMBER
&& day
>= 29))
463 g_assert_cmpint (g_date_get_iso8601_week_of_year (d
), ==, 1);
465 g_assert_cmpint (g_date_get_iso8601_week_of_year (d
) - iso8601_week_of_year
, ==, 1);
469 g_assert_cmpint (g_date_get_monday_week_of_year(d
) - monday_week_of_year
, ==, 0);
470 if (!(day
== 1 && m
== G_DATE_JANUARY
))
471 g_assert_cmpint (g_date_get_iso8601_week_of_year(d
) - iso8601_week_of_year
, ==, 0);
474 monday_week_of_year
= g_date_get_monday_week_of_year (d
);
475 iso8601_week_of_year
= g_date_get_iso8601_week_of_year (d
);
477 g_assert_cmpint (g_date_get_sunday_week_of_year (d
), <=, sunday_weeks_in_year
);
478 g_assert_cmpint (g_date_get_sunday_week_of_year (d
), >=, sunday_week_of_year
);
479 if (g_date_get_weekday(d
) == G_DATE_SUNDAY
)
480 g_assert_cmpint (g_date_get_sunday_week_of_year (d
) - sunday_week_of_year
, ==, 1);
482 g_assert_cmpint (g_date_get_sunday_week_of_year (d
) - sunday_week_of_year
, ==, 0);
484 sunday_week_of_year
= g_date_get_sunday_week_of_year (d
);
486 g_assert_cmpint (g_date_compare (d
, d
), ==, 0);
489 while (i
< 402) /* Need to get 400 year increments in */
492 g_date_add_days (d
, i
);
493 g_assert_cmpint (g_date_compare (d
, &tmp
), >, 0);
494 g_date_subtract_days (d
, i
);
495 g_assert_cmpint (g_date_get_day (d
), ==, day
);
496 g_assert_cmpint (g_date_get_month (d
), ==, m
);
497 g_assert_cmpint (g_date_get_year (d
), ==, y
);
500 g_date_add_months (d
, i
);
501 g_assert_cmpint (g_date_compare (d
, &tmp
), >, 0);
502 g_date_subtract_months (d
, i
);
503 g_assert_cmpint (g_date_get_month (d
), ==, m
);
504 g_assert_cmpint (g_date_get_year (d
), ==, y
);
507 g_assert_cmpint (g_date_get_day (d
), ==, day
);
509 g_date_set_day (d
, day
);
512 g_date_add_years (d
, i
);
513 g_assert_cmpint (g_date_compare (d
, &tmp
), >, 0);
514 g_date_subtract_years (d
, i
);
515 g_assert_cmpint (g_date_get_month (d
), ==, m
);
516 g_assert_cmpint (g_date_get_year (d
), ==, y
);
518 if (m
!= 2 && day
!= 29)
519 g_assert_cmpint (g_date_get_day (d
), ==, day
);
521 g_date_set_day (d
, day
); /* reset */
526 j
= g_date_get_julian (d
);
533 /* at this point, d is the last day of year y */
534 g_date_set_dmy (&tmp
, 1, 1, y
+ 1);
535 g_assert_cmpint (j
+ 1, ==, g_date_get_julian (&tmp
));
537 g_date_add_days (&tmp
, 1);
538 g_assert_cmpint (j
+ 2, ==, g_date_get_julian (&tmp
));
546 g_date_set_dmy (&d1
, 1, 1, 1970);
547 g_date_set_dmy (&d2
, 1, 1, 1980);
548 g_date_set_dmy (&d
, 1, 1, 1);
551 g_date_clamp (&o
, NULL
, NULL
);
552 g_assert (g_date_compare (&o
, &d
) == 0);
554 g_date_clamp (&o
, &d1
, &d2
);
555 g_assert (g_date_compare (&o
, &d1
) == 0);
557 g_date_set_dmy (&o
, 1, 1, 2000);
559 g_date_clamp (&o
, &d1
, &d2
);
560 g_assert (g_date_compare (&o
, &d2
) == 0);
568 g_date_set_dmy (&d1
, 1, 1, 1970);
569 g_date_set_dmy (&d2
, 1, 1, 1980);
571 g_assert (g_date_compare (&d1
, &d2
) == -1);
572 g_date_order (&d2
, &d1
);
573 g_assert (g_date_compare (&d1
, &d2
) == 1);
583 g_assert_false (g_date_valid (d
));
586 g_assert_nonnull (c
);
587 g_assert_false (g_date_valid (c
));
590 g_date_set_day (d
, 10);
593 g_date_set_month (c
, 1);
594 g_date_set_year (c
, 2015);
595 g_assert_true (g_date_valid (c
));
596 g_assert_cmpuint (g_date_get_day (c
), ==, 10);
603 main (int argc
, char** argv
)
608 /* Try to get all the leap year cases. */
609 int check_years
[] = {
610 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
611 11, 12, 13, 14, 98, 99, 100, 101, 102, 103, 397,
612 398, 399, 400, 401, 402, 403, 404, 405, 406,
613 1598, 1599, 1600, 1601, 1602, 1650, 1651,
614 1897, 1898, 1899, 1900, 1901, 1902, 1903,
615 1961, 1962, 1963, 1964, 1965, 1967,
616 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976,
617 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985,
618 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
619 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
620 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
621 3000, 3001, 3002, 3998, 3999, 4000, 4001, 4002, 4003
624 g_setenv ("LC_ALL", "en_US.utf-8", TRUE
);
625 setlocale (LC_ALL
, "");
627 SetThreadLocale (MAKELCID (MAKELANGID (LANG_ENGLISH
, SUBLANG_ENGLISH_US
), SORT_DEFAULT
));
630 g_test_init (&argc
, &argv
, NULL
);
631 g_test_bug_base ("http://bugzilla.gnome.org/");
633 g_test_add_func ("/date/basic", test_basic
);
634 g_test_add_func ("/date/empty", test_empty_constructor
);
635 g_test_add_func ("/date/dmy", test_dmy_constructor
);
636 g_test_add_func ("/date/julian", test_julian_constructor
);
637 g_test_add_func ("/date/dates", test_dates
);
638 g_test_add_func ("/date/parse", test_parse
);
639 g_test_add_func ("/date/month_names", test_month_names
);
640 g_test_add_func ("/date/clamp", test_clamp
);
641 g_test_add_func ("/date/order", test_order
);
642 for (i
= 0; i
< G_N_ELEMENTS (check_years
); i
++)
644 path
= g_strdup_printf ("/date/year/%d", check_years
[i
]);
645 g_test_add_data_func (path
, GINT_TO_POINTER(check_years
[i
]), test_year
);
648 g_test_add_func ("/date/copy", test_copy
);
650 return g_test_run ();