glib/tests/qsort-test.c
branchRCL_3
changeset 56 acd3cd4aaceb
equal deleted inserted replaced
54:4332f0f7be53 56:acd3cd4aaceb
       
     1 /* Portion Copyright © 2008-09 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.*/
       
     2 #undef G_DISABLE_ASSERT
       
     3 #undef G_LOG_DOMAIN
       
     4 
       
     5 #include <glib.h>
       
     6 
       
     7 #include <stdio.h>
       
     8 #ifdef __SYMBIAN32__
       
     9 #include "mrt2_glib2_test.h"
       
    10 #endif /*__SYMBIAN32__*/
       
    11 
       
    12 
       
    13 #define SIZE 100000
       
    14 
       
    15 guint32 array[SIZE];
       
    16 
       
    17 static gint
       
    18 sort (gconstpointer a, gconstpointer b, gpointer user_data)
       
    19 {
       
    20   return *(guint32*)a < *(guint32*)b ? -1 : 1;
       
    21 }
       
    22 
       
    23 int
       
    24 main ()
       
    25 {
       
    26   int i;
       
    27 
       
    28   #ifdef __SYMBIAN32__
       
    29   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);
       
    30   g_set_print_handler(mrtPrintHandler);
       
    31   #endif /*__SYMBIAN32__*/
       
    32 	  
       
    33 
       
    34   for (i = 0; i < SIZE; i++)
       
    35     array[i] = g_random_int ();
       
    36 
       
    37   g_qsort_with_data (array, SIZE, sizeof (guint32), sort, NULL);
       
    38 
       
    39   for (i = 0; i < SIZE - 1; i++)
       
    40     g_assert (array[i] <= array[i+1]);
       
    41 
       
    42   /* 0 elemenents is a valid case */
       
    43   g_qsort_with_data (array, 0, sizeof (guint32), sort, NULL);
       
    44 
       
    45 #ifdef __SYMBIAN32__
       
    46   testResultXml("qsort-test");
       
    47 #endif /* EMULATOR */
       
    48   return 0;
       
    49 }