|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
3 * |
|
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. |
|
8 * |
|
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. |
|
13 * |
|
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. |
|
18 * |
|
19 * Description: |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 |
|
25 #undef G_DISABLE_ASSERT |
|
26 #undef G_LOG_DOMAIN |
|
27 |
|
28 #include <stdio.h> |
|
29 #include <string.h> |
|
30 #include "glib.h" |
|
31 |
|
32 #ifdef SYMBIAN |
|
33 #include "mrt2_glib2_test.h" |
|
34 #endif /*SYMBIAN*/ |
|
35 |
|
36 |
|
37 int main (int argc,char *argv[]) |
|
38 { |
|
39 |
|
40 GDate *date1,*date2,*date; |
|
41 |
|
42 #ifdef SYMBIAN |
|
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); |
|
44 #endif /*SYMBIAN*/ |
|
45 |
|
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); |
|
49 |
|
50 g_assert(g_date_days_between(date1,date2) == 30); |
|
51 g_assert(g_date_days_between(date2,date1) < 0); |
|
52 |
|
53 date1 = g_date_new_dmy(1,G_DATE_MAY,2006); |
|
54 |
|
55 g_assert(g_date_is_first_of_month(date1)); |
|
56 g_assert(g_date_is_last_of_month(date2)); |
|
57 |
|
58 g_date_order(date2,date1); |
|
59 |
|
60 g_assert(date2->day == 1 && date2->month == 5 && date2->year == 2006); |
|
61 g_assert(date1->day == 31 && date1->month == 5 && date1->year == 2006); |
|
62 |
|
63 g_date_set_month(date1,G_DATE_JULY); |
|
64 g_date_set_year(date1,2007); |
|
65 |
|
66 g_assert(date1->month == 7); |
|
67 g_assert(date1->year == 2007); |
|
68 |
|
69 g_date_clamp(date,date2,date1); |
|
70 |
|
71 g_assert(date->day == 1 && date->month == 5 && date->year == 2006); |
|
72 |
|
73 g_date_set_year(date,2008); |
|
74 |
|
75 g_date_clamp(date,date2,date1); |
|
76 |
|
77 g_assert(date->day == 31 && date->month == 7 && date->year == 2007); |
|
78 |
|
79 #if SYMBIAN |
|
80 testResultXml("date_test"); |
|
81 #endif /* EMULATOR */ |
|
82 |
|
83 return 0; |
|
84 } |