glib/tests/unichar-test.c
changeset 72 403e7f6ed6c5
parent 50 79045913e4e9
equal deleted inserted replaced
71:28ccaba883f4 72:403e7f6ed6c5
    14 //
    14 //
    15 
    15 
    16 #undef G_DISABLE_ASSERT
    16 #undef G_DISABLE_ASSERT
    17 #undef G_LOG_DOMAIN
    17 #undef G_LOG_DOMAIN
    18 
    18 
       
    19 #include <sys/stat.h>
    19 #include <glib.h>
    20 #include <glib.h>
    20 #include <errno.h>
    21 #include <errno.h>
    21 #define LOG_FILE "c:\\logs\\unichar_test_log.txt"
    22 #include <glib/gprintf.h>
    22 #include "std_log_result.h"
    23 #ifdef __SYMBIAN32__
    23 #define LOG_FILENAME_LINE __FILE__, __LINE__
    24 #include "mrt2_glib2_test.h"
    24 
    25 #endif /*__SYMBIAN32__*/
    25 void create_xml(int result)
       
    26 {
       
    27     if(result)
       
    28         assert_failed = 1;
       
    29     
       
    30     testResultXml("unichar_testlog");
       
    31     close_log_file();
       
    32 }
       
    33 
    26 
    34 int main (int argc, char *argv[])
    27 int main (int argc, char *argv[])
    35 {  
    28 {  
    36     gunichar ret;
    29     gunichar ret;
    37     gunichar mark = 0x0BCA; //spacing mark. Tamil letter. 
    30     gunichar mark = 0x0BCA; //spacing mark. Tamil letter. 
    39     gunichar square = 0x25A1; //white square
    32     gunichar square = 0x25A1; //white square
    40     gunichar space = 0x200B; //zero width space
    33     gunichar space = 0x200B; //zero width space
    41     gunichar tel_symbol = 0x32C0; //telegraphic symbol for january
    34     gunichar tel_symbol = 0x32C0; //telegraphic symbol for january
    42     gunichar CR = 0x000D; //carriage return
    35     gunichar CR = 0x000D; //carriage return
    43     GUnicodeBreakType type;
    36     GUnicodeBreakType type;
       
    37     #ifdef __SYMBIAN32__
       
    38     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);
       
    39     g_set_print_handler(mrtPrintHandler);
       
    40     #endif /*__SYMBIAN32__*/
    44     
    41     
       
    42     g_print("Test unichar-test Start");
    45     g_unichar_get_mirror_char('(', &ret);
    43     g_unichar_get_mirror_char('(', &ret);
    46     
    44     
    47     if(!(')' == ret))
    45     if(!(')' == ret))
    48         {
    46         {
    49         std_log(LOG_FILENAME_LINE,"g_unichar_get_mirror_char didnt work as expected");
    47         g_print("g_unichar_get_mirror_char didnt work as expected");
    50         assert_failed = 1;
    48         assert_failed = 1;
    51         }
    49         }
    52     
    50     
    53     
    51     
    54     if(!g_unichar_ismark(mark))
    52     if(!g_unichar_ismark(mark))
    55         {
    53         {
    56         std_log(LOG_FILENAME_LINE,"g_unichar_ismark didnt work as expected");
    54         g_print("g_unichar_ismark didnt work as expected");
    57         assert_failed = 1;
    55         assert_failed = 1;
    58         }
    56         }
    59     
    57     
    60     if(!g_unichar_istitle(title))
    58     if(!g_unichar_istitle(title))
    61         {
    59         {
    62         std_log(LOG_FILENAME_LINE,"g_unichar_istitle didnt work as expected");
    60         g_print("g_unichar_istitle didnt work as expected");
    63         assert_failed = 1;
    61         assert_failed = 1;
    64         }
    62         }
    65     
    63     
    66     if(!g_unichar_isdefined(square))
    64     if(!g_unichar_isdefined(square))
    67         {
    65         {
    68         std_log(LOG_FILENAME_LINE,"g_unichar_isdefined didnt work as expected");
    66         g_print("g_unichar_isdefined didnt work as expected");
    69         assert_failed = 1;
    67         assert_failed = 1;
    70         }
    68         }
    71     
    69     
    72     if(!g_unichar_iszerowidth(space))
    70     if(!g_unichar_iszerowidth(space))
    73         {
    71         {
    74         std_log(LOG_FILENAME_LINE,"g_unichar_iszerowidth didnt work as expected");
    72         g_print("g_unichar_iszerowidth didnt work as expected");
    75         assert_failed = 1;
    73         assert_failed = 1;
    76         }
    74         }
    77     
    75     
    78     if(!g_unichar_iswide(tel_symbol))
    76     if(!g_unichar_iswide(tel_symbol))
    79         {
    77         {
    80         std_log(LOG_FILENAME_LINE,"g_unichar_iswide didnt work as expected");
    78         g_print("g_unichar_iswide didnt work as expected");
    81         assert_failed = 1;
    79         assert_failed = 1;
    82         }
    80         }
    83     
    81     
    84     if(!g_unichar_iswide_cjk(tel_symbol))
    82     if(!g_unichar_iswide_cjk(tel_symbol))
    85         {
    83         {
    86         std_log(LOG_FILENAME_LINE,"g_unichar_iswide_cjk didnt work as expected");
    84         g_print("g_unichar_iswide_cjk didnt work as expected");
    87         assert_failed = 1;
    85         assert_failed = 1;
    88         }
    86         }
    89     
    87     
    90     ret = g_unichar_totitle('a');
    88     ret = g_unichar_totitle('a');
    91     if(!(ret == 'A'))
    89     if(!(ret == 'A'))
    92         {
    90         {
    93         std_log(LOG_FILENAME_LINE,"g_unichar_totitle didnt work as expected");
    91         g_print("g_unichar_totitle didnt work as expected");
    94         assert_failed = 1;
    92         assert_failed = 1;
    95         }
    93         }
    96     
    94     
    97     type = g_unichar_break_type(CR);
    95     type = g_unichar_break_type(CR);
    98     if(type != G_UNICODE_BREAK_CARRIAGE_RETURN)
    96     if(type != G_UNICODE_BREAK_CARRIAGE_RETURN)
    99         {
    97         {
   100         std_log(LOG_FILENAME_LINE,"g_unichar_break_type didnt work as expected");
    98         g_print("g_unichar_break_type didnt work as expected");
   101         assert_failed = 1;
    99         assert_failed = 1;
   102         }
   100         }
   103     
   101     
   104 	if(assert_failed)
   102 	if(assert_failed)
   105           std_log(LOG_FILENAME_LINE,"Test Failed");
   103           g_print("Test unichar-test Failed");
   106     else
   104     else
   107           std_log(LOG_FILENAME_LINE,"Test Successful");
   105           g_print("Test unichar-test Successful");
   108 	
   106 	
   109     create_xml(0);
   107     #if __SYMBIAN32__
   110 
   108     testResultXml("unichar-test");
       
   109     #endif /* EMULATOR */
   111 	return 0;
   110 	return 0;
   112 }
   111 }