|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #undef G_DISABLE_ASSERT |
|
19 #undef G_LOG_DOMAIN |
|
20 |
|
21 #include <glib.h> |
|
22 |
|
23 #include <stdio.h> |
|
24 #ifdef __SYMBIAN32__ |
|
25 #include "mrt2_glib2_test.h" |
|
26 #endif /*__SYMBIAN32__*/ |
|
27 |
|
28 |
|
29 #define SIZE 100000 |
|
30 |
|
31 guint32 array[SIZE]; |
|
32 |
|
33 static gint |
|
34 sort (gconstpointer a, gconstpointer b, gpointer user_data) |
|
35 { |
|
36 return *(guint32*)a < *(guint32*)b ? -1 : 1; |
|
37 } |
|
38 |
|
39 int |
|
40 main () |
|
41 { |
|
42 int i; |
|
43 |
|
44 #ifdef __SYMBIAN32__ |
|
45 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); |
|
46 g_set_print_handler(mrtPrintHandler); |
|
47 #endif /*__SYMBIAN32__*/ |
|
48 |
|
49 |
|
50 for (i = 0; i < SIZE; i++) |
|
51 array[i] = g_random_int (); |
|
52 |
|
53 g_qsort_with_data (array, SIZE, sizeof (guint32), sort, NULL); |
|
54 |
|
55 for (i = 0; i < SIZE - 1; i++) |
|
56 g_assert (array[i] <= array[i+1]); |
|
57 |
|
58 /* 0 elemenents is a valid case */ |
|
59 g_qsort_with_data (array, 0, sizeof (guint32), sort, NULL); |
|
60 |
|
61 #ifdef __SYMBIAN32__ |
|
62 testResultXml("qsort-test"); |
|
63 #endif /* EMULATOR */ |
|
64 return 0; |
|
65 } |