1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/glib/tsrc/BC/tests/testgdateparser.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,93 @@
1.4 +/* Portion Copyright © 2008-09 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.*/
1.5 +#undef G_DISABLE_ASSERT
1.6 +#undef G_LOG_DOMAIN
1.7 +
1.8 +#ifdef GLIB_COMPILATION
1.9 +#undef GLIB_COMPILATION
1.10 +#endif
1.11 +
1.12 +#include "glib.h"
1.13 +
1.14 +#include <stdio.h>
1.15 +#include <string.h>
1.16 +#include <locale.h>
1.17 +
1.18 +#ifdef SYMBIAN
1.19 +#include "mrt2_glib2_test.h"
1.20 +#endif /*SYMBIAN*/
1.21 +
1.22 +
1.23 +void g_date_debug_print(GDate* d)
1.24 +{
1.25 + if (!d) g_print("NULL!\n");
1.26 + else
1.27 + g_print("julian: %u (%s) DMY: %u %u %u (%s)\n",
1.28 + d->julian_days,
1.29 + d->julian ? "valid" : "invalid",
1.30 + d->day,
1.31 + d->month,
1.32 + d->year,
1.33 + d->dmy ? "valid" : "invalid");
1.34 +
1.35 + fflush(stdout);
1.36 +}
1.37 +
1.38 +/* These only work in the POSIX locale, maybe C too -
1.39 + * type POSIX into the program to check them
1.40 + */
1.41 +char* posix_tests [] = {
1.42 + "19981024",
1.43 + "981024",
1.44 + "October 1998",
1.45 + "October 98",
1.46 + "oCT 98",
1.47 + "10/24/98",
1.48 + "10 -- 24 -- 98",
1.49 + "10/24/1998",
1.50 + "October 24, 1998",
1.51 + NULL
1.52 +};
1.53 +
1.54 +int main(int argc, char** argv)
1.55 +{
1.56 + GDate* d;
1.57 + gchar* loc;
1.58 + char** s = posix_tests;
1.59 +
1.60 + #ifdef SYMBIAN
1.61 + 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);
1.62 + g_set_print_handler(mrtPrintHandler);
1.63 + #endif /*SYMBIAN*/
1.64 +
1.65 +
1.66 + loc = setlocale(LC_ALL,"");
1.67 +
1.68 + d = g_date_new();
1.69 +
1.70 + while (*s)
1.71 + {
1.72 + g_date_set_parse(d, *s);
1.73 +
1.74 + if (!g_date_valid(d))
1.75 + {
1.76 + g_print(" failed.\n");
1.77 + g_assert(FALSE && "testgdateparser");
1.78 + }
1.79 + else
1.80 + {
1.81 + gchar buf[256];
1.82 +
1.83 + g_date_strftime(buf,100," parsed `%x' (%B %d %Y)\n",
1.84 + d);
1.85 + }
1.86 + ++s;
1.87 + }
1.88 +
1.89 + g_date_free(d);
1.90 +#ifdef SYMBIAN
1.91 + testResultXml("testgdateparser");
1.92 +#endif /* EMULATOR */
1.93 + return 0;
1.94 +}
1.95 +
1.96 +