|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #undef G_DISABLE_ASSERT |
|
22 #undef G_LOG_DOMAIN |
|
23 |
|
24 #include <stdio.h> |
|
25 #include <string.h> |
|
26 #include "glib.h" |
|
27 |
|
28 #ifdef __SYMBIAN32__ |
|
29 #include "mrt2_glib2_test.h" |
|
30 #endif /*__SYMBIAN32__*/ |
|
31 |
|
32 |
|
33 int main (int argc,char *argv[]) |
|
34 { |
|
35 |
|
36 GDate *date1,*date2,*date; |
|
37 |
|
38 #ifdef __SYMBIAN32__ |
|
39 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); |
|
40 #endif /*__SYMBIAN32__*/ |
|
41 |
|
42 date = g_date_new_dmy(1,G_DATE_MAY,2003); |
|
43 date1 = g_date_new_dmy(1,G_DATE_MAY,2006); |
|
44 date2 = g_date_new_dmy(31,G_DATE_MAY,2006); |
|
45 |
|
46 g_assert(g_date_days_between(date1,date2) == 30); |
|
47 g_assert(g_date_days_between(date2,date1) < 0); |
|
48 |
|
49 date1 = g_date_new_dmy(1,G_DATE_MAY,2006); |
|
50 |
|
51 g_assert(g_date_is_first_of_month(date1)); |
|
52 g_assert(g_date_is_last_of_month(date2)); |
|
53 |
|
54 g_date_order(date2,date1); |
|
55 |
|
56 g_assert(date2->day == 1 && date2->month == 5 && date2->year == 2006); |
|
57 g_assert(date1->day == 31 && date1->month == 5 && date1->year == 2006); |
|
58 |
|
59 g_date_set_month(date1,G_DATE_JULY); |
|
60 g_date_set_year(date1,2007); |
|
61 |
|
62 g_assert(date1->month == 7); |
|
63 g_assert(date1->year == 2007); |
|
64 |
|
65 g_date_clamp(date,date2,date1); |
|
66 |
|
67 g_assert(date->day == 1 && date->month == 5 && date->year == 2006); |
|
68 |
|
69 g_date_set_year(date,2008); |
|
70 |
|
71 g_date_clamp(date,date2,date1); |
|
72 |
|
73 g_assert(date->day == 31 && date->month == 7 && date->year == 2007); |
|
74 |
|
75 #if __SYMBIAN32__ |
|
76 testResultXml("date_test"); |
|
77 #endif /* EMULATOR */ |
|
78 |
|
79 return 0; |
|
80 } |