sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General Public sl@0: * License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place - Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: #include sl@0: #include sl@0: #include "glib.h" sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: sl@0: int main (int argc,char *argv[]) sl@0: { sl@0: sl@0: GDate *date1,*date2,*date; sl@0: sl@0: #ifdef SYMBIAN sl@0: 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); sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: date = g_date_new_dmy(1,G_DATE_MAY,2003); sl@0: date1 = g_date_new_dmy(1,G_DATE_MAY,2006); sl@0: date2 = g_date_new_dmy(31,G_DATE_MAY,2006); sl@0: sl@0: g_assert(g_date_days_between(date1,date2) == 30); sl@0: g_assert(g_date_days_between(date2,date1) < 0); sl@0: sl@0: date1 = g_date_new_dmy(1,G_DATE_MAY,2006); sl@0: sl@0: g_assert(g_date_is_first_of_month(date1)); sl@0: g_assert(g_date_is_last_of_month(date2)); sl@0: sl@0: g_date_order(date2,date1); sl@0: sl@0: g_assert(date2->day == 1 && date2->month == 5 && date2->year == 2006); sl@0: g_assert(date1->day == 31 && date1->month == 5 && date1->year == 2006); sl@0: sl@0: g_date_set_month(date1,G_DATE_JULY); sl@0: g_date_set_year(date1,2007); sl@0: sl@0: g_assert(date1->month == 7); sl@0: g_assert(date1->year == 2007); sl@0: sl@0: g_date_clamp(date,date2,date1); sl@0: sl@0: g_assert(date->day == 1 && date->month == 5 && date->year == 2006); sl@0: sl@0: g_date_set_year(date,2008); sl@0: sl@0: g_date_clamp(date,date2,date1); sl@0: sl@0: g_assert(date->day == 31 && date->month == 7 && date->year == 2007); sl@0: sl@0: #if SYMBIAN sl@0: testResultXml("date_test"); sl@0: #endif /* EMULATOR */ sl@0: sl@0: return 0; sl@0: }