glib/tests/nullify-ptr.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 #define LOG_FILE "c:\\logs\\nullify_ptr_log.txt"
    21 #include <glib/gprintf.h>
    21 #include "std_log_result.h"
    22 #ifdef __SYMBIAN32__
    22 #define LOG_FILENAME_LINE __FILE__, __LINE__
    23 #include "mrt2_glib2_test.h"
    23 
    24 #endif /*__SYMBIAN32__*/
    24 void create_xml(int result)
       
    25 {
       
    26     if(result)
       
    27         assert_failed = 1;
       
    28     
       
    29     testResultXml("nullify_ptr_log");
       
    30     close_log_file();
       
    31 }
       
    32 
    25 
    33 int main (int argc, char *argv[])
    26 int main (int argc, char *argv[])
    34 {
    27 {
    35     char *ptr;
    28     char *ptr;
    36 	g_nullify_pointer((gpointer)&ptr);
    29     #ifdef __SYMBIAN32__
       
    30     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);
       
    31     g_set_print_handler(mrtPrintHandler);
       
    32     #endif /*__SYMBIAN32__*/
       
    33 	
       
    34     g_print("Test nullify-ptr Start");
       
    35     g_nullify_pointer((gpointer)&ptr);
    37 	
    36 	
    38 	if(ptr != NULL)
    37 	if(ptr != NULL)
    39 	    {
    38 	    {
    40         std_log(LOG_FILENAME_LINE,"ptr is not NULL");
    39         g_print("ptr is not NULL");
    41 	    assert_failed = 1;
    40 	    assert_failed = 1;
    42 	    }
    41 	    }
    43 	
    42 	
    44 	if(assert_failed)
    43 	if(assert_failed)
    45           std_log(LOG_FILENAME_LINE,"Test Fail");
    44           g_print("Test nullify-ptr Fail");
    46     else
    45     else
    47           std_log(LOG_FILENAME_LINE,"Test Successful");
    46           g_print("Test nullify-ptr Successful");
    48 	
    47 	
    49     create_xml(0);
    48     #if __SYMBIAN32__
       
    49     testResultXml("nullify-ptr");
       
    50     #endif /* EMULATOR */
    50 
    51 
    51 	return 0;
    52 	return 0;
    52 }
    53 }