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