First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #undef G_DISABLE_ASSERT
33 #include "mrt2_glib2_test.h"
37 int main (int argc,char *argv[])
40 GDate *date1,*date2,*date;
43 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
46 date = g_date_new_dmy(1,G_DATE_MAY,2003);
47 date1 = g_date_new_dmy(1,G_DATE_MAY,2006);
48 date2 = g_date_new_dmy(31,G_DATE_MAY,2006);
50 g_assert(g_date_days_between(date1,date2) == 30);
51 g_assert(g_date_days_between(date2,date1) < 0);
53 date1 = g_date_new_dmy(1,G_DATE_MAY,2006);
55 g_assert(g_date_is_first_of_month(date1));
56 g_assert(g_date_is_last_of_month(date2));
58 g_date_order(date2,date1);
60 g_assert(date2->day == 1 && date2->month == 5 && date2->year == 2006);
61 g_assert(date1->day == 31 && date1->month == 5 && date1->year == 2006);
63 g_date_set_month(date1,G_DATE_JULY);
64 g_date_set_year(date1,2007);
66 g_assert(date1->month == 7);
67 g_assert(date1->year == 2007);
69 g_date_clamp(date,date2,date1);
71 g_assert(date->day == 1 && date->month == 5 && date->year == 2006);
73 g_date_set_year(date,2008);
75 g_date_clamp(date,date2,date1);
77 g_assert(date->day == 31 && date->month == 7 && date->year == 2007);
80 testResultXml("date_test");